cdf2density: numerically compute a density from a cdf

View source: R/helpers.R

cdf2densityR Documentation

numerically compute a density from a cdf

Description

The function tries to keep the (open) support, by using a one sided derivative at limits of the support, while using a two sided in the middle of the support.

Usage

cdf2density(cdf, ..., .args = list(...), eps = 1e-07, cdf2 = NULL)

Arguments

cdf

the cummulative distribution function to be derived

...

futher named parameters for cdf

.args

the further named parameters given as a list

eps

the distance to be used in the numerical derivative

cdf2

a function representing the cdf of the reference measure. NULL uses a simplification for Lebesque reference.

Value

a vectorized function giving the density obtained by numerically differentiating 'cdf' (a one-sided difference at the boundaries of the support, a two-sided difference in the interior). If 'cdf2' is supplied the result is the density relative to that reference measure instead of the Lebesgue density.

Examples

dUnif = cdf2density(punif,min=-0.2,0.4)
x=seq(-1,2,by=0.01)
plot(x,dUnif(x))


DistributionalDDA documentation built on Oct. 20, 2026, 5:06 p.m.