# Quantile (quantile)

The smallest value with at least a share q of a list, or a chance q of a distribution, at or below it.

## How to write it

### quantile(data, q)

The value at position ceil(n q) in order, or the first for q = 0. It is never between two values.

**data**

The numbers. They are put in order, so symbols are not allowed. Takes a list.

**q**

A share from 0 to 1, or a list of them. Takes a number, or a list.

### quantile(distribution, q)

The value that a variable with the distribution stays at or below with chance q: the inverse of cdf.

**distribution**

A normal, lognormal, uniform, exponential or Weibull distribution. Takes an expression.

**q**

The chance, a number above 0 and below 1, or a symbol. Takes an expression.

## Examples

- $\displaystyle \operatorname{quantile}\left(\left[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 \right], \frac{1}{4}\right) = 3$

  `quantile([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 1/4)`

  In the solver, `quantile([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 1/4)` gives `3`.

  [Open in the solver](https://hilberon.com/?q=quantile%28%5B1%2C%202%2C%203%2C%204%2C%205%2C%206%2C%207%2C%208%2C%209%2C%2010%5D%2C%201%2F4%29)
- $\displaystyle \operatorname{quantile}\left(\left[ 5, 1, 4, 2, 3 \right], \left[ 0, \frac{1}{2}, 1 \right]\right) = \left[ 1, 3, 5 \right]$

  `quantile([5, 1, 4, 2, 3], [0, 1/2, 1])`

  In the solver, `quantile([5, 1, 4, 2, 3], [0, 1/2, 1])` gives `[1, 3, 5]`.

  [Open in the solver](https://hilberon.com/?q=quantile%28%5B5%2C%201%2C%204%2C%202%2C%203%5D%2C%20%5B0%2C%201%2F2%2C%201%5D%29)
- $\displaystyle \operatorname{quantile}\left(\operatorname{normal\_distribution}(0, 1), \frac{19}{20}\right) = \sqrt{2} \operatorname{erf}^{-1}\left(\frac{9}{10}\right)$

  `quantile(normal_distribution(0, 1), 19/20)`

  In the solver, `quantile(normal_distribution(0, 1), 19/20)` gives `sqrt(2)*inverse_erf(9/10)`.

  [Open in the solver](https://hilberon.com/?q=quantile%28normal_distribution%280%2C%201%29%2C%2019%2F20%29)
- $\displaystyle \operatorname{quantile}(\operatorname{exponential\_distribution}(\lambda), q) = -\frac{\ln(1-q)}{\lambda}$

  `quantile(exponential_distribution(lambda), q)`

  In the solver, `quantile(exponential_distribution(lambda), q)` gives `-ln(1 - q)/lambda`.

  [Open in the solver](https://hilberon.com/?q=quantile%28exponential_distribution%28lambda%29%2C%20q%29)

## Functions its examples use

- [normal_distribution](https://hilberon.com/library/normal_distribution)

  The normal distribution with mean mu and standard deviation sigma.
- [exponential_distribution](https://hilberon.com/library/exponential_distribution)

  The waiting time for events that come at rate lambda.

## Related functions

- [standard_deviation](https://hilberon.com/library/standard_deviation)

  The sample standard deviation of a list of numbers, or that of a distribution.
- [probability](https://hilberon.com/library/probability)

  The probability that a condition holds for a variable with a distribution.
- [stationary_distribution](https://hilberon.com/library/stationary_distribution)

  The law a process settles into over time, when it has one.
- [poisson_distribution](https://hilberon.com/library/poisson_distribution)

  The number of events in a period when they come at an average rate lambda.
- [uniform_distribution](https://hilberon.com/library/uniform_distribution)

  The continuous distribution that is equally likely anywhere between a and b.
- [pdf](https://hilberon.com/library/pdf)

  The density of a distribution at a point, or the probability of a value for a discrete one.

---
Source: https://hilberon.com/library/quantile
