Quantiles for objects of class `density`

```
# S3 method for density
quantile(x, probs = seq(0.25, 0.75, 0.25), names = TRUE, normalize = TRUE, ...)
```

## Arguments

- x
a object of class `density`

or a list of densities

- probs
numeric vector of probabilities with values in [0,1]. Note that
elements very close to the boundaries return `Inf`

or `-Inf`

- names
logical; if `TRUE`

, the result has a names attribute, resp.
a rownames and colnames attributes. Set to `FALSE`

for speedup with
many probabilities

- normalize
logical; if `TRUE`

then the values in `x$y`

are
multiplied with a factor such that their integral is equal to one.

- ...
further arguments passed to or from other methods (currently
unused)

## Value

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.

## Details

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
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.

## Examples

```
rNorm_dens <- density(rnorm(100000))
quantile(rNorm_dens)
#> 25% 50% 75%
#> -0.676958638 0.002327997 0.680674963
```