Generic function to find the quantiles of a distribution, given the equivalent probability distribution function.
qgeneric(pdist, p, matargs = NULL, scalarargs = NULL, ...)
pdist | Probability distribution function, for example,
|
---|---|
p | Vector of probabilities to find the quantiles for. |
matargs | Character vector giving the elements of |
scalarargs | Character vector naming scalar arguments of the distribution function that cannot be vectorised. This is used for the arguments |
... | The remaining arguments define parameters of the distribution
This may also contain the standard arguments If the distribution is bounded above or below, then this should contain
arguments |
Vector of quantiles of the distribution at p
.
This function is used by default for custom distributions for which a quantile function is not provided.
It works by finding the root of the equation \(h(q) = pdist(q) - p = 0\).
Starting from the interval \((-1, 1)\), the interval width is expanded by
50% until \(h()\) is of opposite sign at either end. The root is then
found using uniroot
.
This assumes a suitably smooth, continuous distribution.
Christopher Jackson <chris.jackson@mrc-bsu.cam.ac.uk>
#> [1] -1.959964 1.959964#> [1] -1.959964 1.959964