quantile.density | R Documentation |
Quantiles for objects of class density
## S3 method for class 'density'
quantile(x, probs = seq(0.25, 0.75, 0.25), names = TRUE, normalize = TRUE, ...)
x |
a object of class |
probs |
numeric vector of probabilities with values in [0,1]. Note that
elements very close to the boundaries return |
names |
logical; if |
normalize |
logical; if |
... |
further arguments passed to or from other methods (currently unused) |
This function is a near-exact copy of the quantile.density
function from package BMS (https://CRAN.R-project.org/package=BMS).
In spring of 2022, CRAN informed us that the BMS has been orphaned, so we
copied the code (and corresponding documentation) we needed from it. See
\Sexpr[results=rd]{tools:::Rd_expr_doi("10.18637/jss.v068.i04")} for their paper.
The function quantile.density()
applies generically to the built-in
class density
(as least for versions where there is no such method
in the pre-configured packages). Note that this function relies on
trapezoidal integration in order to compute the cumulative densities
necessary for the calculation of quantiles.
If x is of class density
(or a list with exactly one element),
a vector with quantiles. If x is a list of densities, then the output is a
matrix of quantiles, with each matrix row corresponding to the respective
density.
Stefan Zeugner, stefan.zeugner@ec.europa.eu
Martin Feldkircher, martin.feldkircher@da-vienna.ac.at
rNorm_dens <- density(rnorm(100000))
quantile(rNorm_dens)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.