[Experimental]

The CDF distribution is a non-parametric distribution defined by the cumulative probabilities at a set of values. This distribution is useful for representing empirical distributions or elicited expert knowledge when only the probability of being below some values is available. The distribution uses linear interpolation between the given points and can be used to approximate complex distributions that may not have simple parametric forms.

The same distribution can be described by the values at a set of cumulative probabilities rather than the cumulative probabilities at a set of values, which is provided by dist_quantile(). Since the interpolation between the given points is linear, and linear interpolation is its own inverse, dist_cdf(x, p) and dist_quantile(x, p) describe exactly the same distribution.

dist_cdf(x, cdf)

Arguments

x

A list of values

cdf

A list of cumulative probabilities (between 0 and 1) at x

Details

We recommend reading this documentation on pkgdown which renders math nicely. https://pkg.mitchelloharawild.com/distributional/reference/dist_cdf.html

In the following, let \(X\) be a CDF random variable defined by the cumulative probabilities \(p_1, p_2, \ldots, p_n\) at the values \(x_1, x_2, \ldots, x_n\) where \(0 \le p_i \le 1\).

Support: \([\min(x_i), \max(x_i)]\) if \(\min(p_i) > 0\) or \(\max(p_i) < 1\), otherwise support is approximated from the specified cumulative probabilities.

Mean: Approximated numerically using spline interpolation and numerical integration:

$$ E(X) \approx \int_0^1 Q(u) du $$

where \(Q(u)\) is a spline function interpolating the values.

Variance: Approximated numerically.

Probability density function (p.d.f): Approximated numerically using kernel density estimation from generated samples.

Cumulative distribution function (c.d.f): Defined by linear interpolation:

$$ F(t) = \begin{cases} p_1 & \text{if } t < x_1 \\ p_i + \frac{(t - x_i)(p_{i+1} - p_i)}{x_{i+1} - x_i} & \text{if } x_i \le t < x_{i+1} \\ p_n & \text{if } t \ge x_n \end{cases} $$

Quantile function: Defined by linear interpolation:

$$ Q(u) = x_i + \frac{(u - p_i)(x_{i+1} - x_i)}{p_{i+1} - p_i} $$

for \(p_i \le u \le p_{i+1}\).

Examples

# A distribution given by its cumulative distribution function over a grid
at <- seq(-3, 3, by = 0.1)
dist <- dist_cdf(list(at), list(pnorm(at)))

dist
#> <distribution[1]>
#> [1] cdf[61]
cdf(dist, 1.96)
#> [1] 0.9748633
quantile(dist, 0.975)
#> [1] 1.962291

# The same distribution described by its quantiles
dist_quantile(list(at), list(pnorm(at)))
#> <distribution[1]>
#> [1] quantile[61]