Given a kernel estimate of a probability density, compute quantiles.

```
# S3 method for density
quantile(x, probs = seq(0, 1, 0.25), names = TRUE,
..., warn = TRUE)
```

A numeric vector containing the quantiles.

- x
Object of class

`"density"`

computed by a method for`density`

- probs
Numeric vector of probabilities for which the quantiles are required.

- names
Logical value indicating whether to attach names (based on

`probs`

) to the result.- ...
Ignored.

- warn
Logical value indicating whether to issue a warning if the density estimate

`x`

had to be renormalised because it was computed in a restricted interval.

Adrian Baddeley Adrian.Baddeley@curtin.edu.au

Rolf Turner r.turner@auckland.ac.nz

and Ege Rubak rubak@math.aau.dk

This function calculates quantiles of the probability distribution
whose probability density has been estimated and stored in the object
`x`

. The object `x`

must belong to the class `"density"`

,
and would typically have been obtained from a call to the function
`density`

.

The probability density is first normalised so that the total
probability is equal to 1. A warning is issued if the density
estimate was restricted to an interval (i.e. if `x`

was created by a call to `density`

which
included either of the arguments `from`

and `to`

).

Next, the density estimate is numerically integrated to obtain an estimate of the cumulative distribution function \(F(x)\). Then for each desired probability \(p\), the algorithm finds the corresponding quantile \(q\).

The quantile \(q\) corresponding to probability \(p\)
satisfies \(F(q) = p\) up to
the resolution of the grid of values contained in `x`

.
The quantile is computed from the right, that is,
\(q\) is the smallest available value of \(x\) such that
\(F(x) \ge p\).

`quantile`

,
`quantile.ewcdf`

,
`quantile.im`

,
`CDF`

.

```
dd <- density(runif(10))
quantile(dd)
```

Run the code above in your browser using DataLab