View source: R/dist_percentile.R
| dist_quantile | R Documentation |
The Quantile distribution is a non-parametric distribution defined by a set of values at specified quantile probabilities. This distribution is useful for representing empirical distributions or elicited expert knowledge when only quantile information is available. The distribution uses linear interpolation between quantiles and can be used to approximate complex distributions that may not have simple parametric forms.
dist_quantile(x, quantile)
dist_percentile(x, percentile)
x |
A list of values |
quantile |
A list of quantile probabilities (between 0 and 1) |
percentile |
A list of percentiles (between 0 and 100) |
We recommend reading this documentation on pkgdown which renders math nicely. https://pkg.mitchelloharawild.com/distributional/reference/dist_quantile.html
In the following, let X be a Quantile random variable defined by
values x_1, x_2, \ldots, x_n at quantile probabilities
q_1, q_2, \ldots, q_n where 0 \le q_i \le 1.
Support: [\min(x_i), \max(x_i)] if \min(q_i) > 0 or
\max(q_i) < 1, otherwise support is approximated from the
specified quantiles.
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 quantile 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}
q_1 & \text{if } t < x_1 \\
q_i + \frac{(t - x_i)(q_{i+1} - q_i)}{x_{i+1} - x_i} & \text{if } x_i \le t < x_{i+1} \\
q_n & \text{if } t \ge x_n
\end{cases}
Quantile function: Defined by linear interpolation:
Q(u) = x_i + \frac{(u - q_i)(x_{i+1} - x_i)}{q_{i+1} - q_i}
for q_i \le u \le q_{i+1}.
dist <- dist_normal()
probs <- seq(0.01, 0.99, by = 0.01)
x <- vapply(probs, quantile, double(1L), x = dist)
dist_quantile(list(x), list(probs))
dist_percentile(list(x), list(probs * 100))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.