[Experimental] Return functions with density-like, distribution-like, or quantile-like interfaces from a supplied density or distribution function.

PDF(.f, ...)

CDF(.f, lower = -Inf, ...)

Quantile(cdf, interval = c(-100, 100))

Arguments

.f

Function. Density function used by PDF() or integrated by CDF().

...

Additional arguments passed to .f.

lower

Numeric. Lower integration bound used by CDF().

cdf

Function. Cumulative distribution function used by Quantile().

interval

Numeric vector of length two. Search interval used by Quantile() when solving for roots.

Value

  • PDF() returns a function with arguments x and log.

  • CDF() returns a function with arguments x, lower.tail, and log.p.

  • Quantile() returns a function with arguments p, log.p, and lower.tail.

Examples

pdf <- PDF(dnorm, mean = 0.3, sd = 1.3)
pdf(3)
#> [1] 0.03550408

cdf <- CDF(dnorm, mean = 0.3, sd = 1.3)
cdf(3)
#> [1] 0.9810957

pnorm(Quantile(pnorm)(0.9))
#> [1] 0.9