Quantile function explained

In probability and statistics, the quantile function outputs the value of a random variable such that its probability is less than or equal to an input probability value. Intuitively, the quantile function associates with a range at and below a probability input the likelihood that a random variable is realized in that range for some probability distribution. It is also called the percentile function (after the percentile), percent-point function, inverse cumulative distribution function (after the cumulative distribution function or c.d.f.) or inverse distribution function.

Definition

Strictly monotonic distribution function

FX\colonR\to[0,1]

of a random variable X, the quantile function

Q\colon[0,1]\toR

maps its input p to a threshold value x so that the probability of X being less or equal than x is p. In terms of the distribution function F, the quantile function Q returns the value x such that

FX(x):=\Pr(X\lex)=p,

which can be written as inverse of the c.d.f.

Q(p)

-1
=F
X

(p).

General distribution function

In the general case of distribution functions that are not strictly monotonic and therefore do not permit an inverse c.d.f., the quantile is a (potentially) set valued functional of a distribution function, given by the interval[1]

Q(p) = \boldsymbol{l[}\sup\left\{x\colonF(x)<p\right\}\boldsymbol{,}\sup\left\{x\colonF(x)\lep\right\}\boldsymbol{r]}~.

It is often standard to choose the lowest value, which can equivalently be written as (using right-continuity of)

Q(p) = inf\left\{x\inR:p\leF(x)\right\}~.

Here we capture the fact that the quantile function returns the minimum value of from amongst all those values whose c.d.f value exceeds, which is equivalent to the previous probability statement in the special case that the distribution is continuous. Note that the infimum function can be replaced by the minimum function, since the distribution function is right-continuous and weakly monotonically increasing.

The quantile is the unique function satisfying the Galois inequalities

Q(p)\lex

if and only if

p\leF(x)~.

If the function is continuous and strictly monotonically increasing, then the inequalities can be replaced by equalities, and we have:

Q=F-1

In general, even though the distribution function may fail to possess a left or right inverse, the quantile function behaves as an "almost sure left inverse" for the distribution function, in the sense that

Ql(F(X)r)=X

almost surely.

Simple example

For example, the cumulative distribution function of Exponential(λ) (i.e. intensity λ and expected value (mean) 1/λ) is

F(x;λ)=\begin{cases} 1-e&x\ge0,\\ 0&x<0. \end{cases}

The quantile function for Exponential(λ) is derived by finding the value of Q for which

1-e=p

:

Q(p;λ)=

-ln(1-p)
λ

,

for 0 ≤ p < 1. The quartiles are therefore:

first quartile (p = 1/4):

-ln(3/4)/λ

median (p = 2/4) :

-ln(1/2)/λ

third quartile (p = 3/4) :

-ln(1/4)/λ.

Applications

Quantile functions are used in both statistical applications and Monte Carlo methods.

The quantile function is one way of prescribing a probability distribution, and it is an alternative to the probability density function (pdf) or probability mass function, the cumulative distribution function (cdf) and the characteristic function. The quantile function, Q, of a probability distribution is the inverse of its cumulative distribution function F. The derivative of the quantile function, namely the quantile density function, is yet another way of prescribing a probability distribution. It is the reciprocal of the pdf composed with the quantile function.

Consider a statistical application where a user needs to know key percentage points of a given distribution. For example, they require the median and 25% and 75% quartiles as in the example above or 5%, 95%, 2.5%, 97.5% levels for other applications such as assessing the statistical significance of an observation whose distribution is known; see the quantile entry. Before the popularization of computers, it was not uncommon for books to have appendices with statistical tables sampling the quantile function.[2] Statistical applications of quantile functions are discussed extensively by Gilchrist.[3]

Monte-Carlo simulations employ quantile functions to produce non-uniform random or pseudorandom numbers for use in diverse types of simulation calculations. A sample from a given distribution may be obtained in principle by applying its quantile function to a sample from a uniform distribution. The demands of simulation methods, for example in modern computational finance, are focusing increasing attention on methods based on quantile functions, as they work well with multivariate techniques based on either copula or quasi-Monte-Carlo methods[4] and Monte Carlo methods in finance.

Calculation

The evaluation of quantile functions often involves numerical methods, such as the exponential distribution above, which is one of the few distributions where a closed-form expression can be found (others include the uniform, the Weibull, the Tukey lambda (which includes the logistic) and the log-logistic). When the cdf itself has a closed-form expression, one can always use a numerical root-finding algorithm such as the bisection method to invert the cdf. Other methods rely on an approximation of the inverse via interpolation techniques.[5] [6] Further algorithms to evaluate quantile functions are given in the Numerical Recipes series of books. Algorithms for common distributions are built into many statistical software packages. General methods to numerically compute the quantile functions for general classes of distributions can be found in the following libraries:

Quantile functions may also be characterized as solutions of non-linear ordinary and partial differential equations. The ordinary differential equations for the cases of the normal, Student, beta and gamma distributions have been given and solved.[11]

Normal distribution

The normal distribution is perhaps the most important case. Because the normal distribution is a location-scale family, its quantile function for arbitrary parameters can be derived from a simple transformation of the quantile function of the standard normal distribution, known as the probit function. Unfortunately, this function has no closed-form representation using basic algebraic functions; as a result, approximate representations are usually used. Thorough composite rational and polynomial approximations have been given by Wichura[12] and Acklam.[13] Non-composite rational approximations have been developed by Shaw.[14]

Ordinary differential equation for the normal quantile

A non-linear ordinary differential equation for the normal quantile, w(p), may be given. It is

d2w
dp2

=w\left(

dw
dp

\right)2

with the centre (initial) conditions

w\left(1/2\right)=0,

w'\left(1/2\right)=\sqrt{2\pi}.

This equation may be solved by several methods, including the classical power series approach. From this solutions of arbitrarily high accuracy may be developed (see Steinbrecher and Shaw, 2008).

Student's t-distribution

This has historically been one of the more intractable cases, as the presence of a parameter, ν, the degrees of freedom, makes the use of rational and other approximations awkward. Simple formulas exist when the ν = 1, 2, 4 and the problem may be reduced to the solution of a polynomial when ν is even. In other cases the quantile functions may be developed as power series.[15] The simple cases are as follows:

ν = 1 (Cauchy distribution)

See main article: Cauchy distribution.

Q(p)=\tan(\pi(p-1/2))

ν = 2

Q(p)=2(p-1/2)\sqrt{

2
\alpha
}\!
ν = 4

Q(p)=\operatorname{sign}(p-1/2)2\sqrt{q-1}

where

q=

\cos\left(
1
3
\arccos\left(\sqrt{\alpha

\right)\right)}{\sqrt{\alpha}}

and

\alpha=4p(1-p).

In the above the "sign" function is +1 for positive arguments, −1 for negative arguments and zero at zero. It should not be confused with the trigonometric sine function.

Quantile mixtures

Analogously to the mixtures of densities, distributions can be defined as quantile mixtures

m
Q(p)=\sum
i=1

aiQi(p)

,where

Qi(p)

,

i=1,\ldots,m

are quantile functions and

ai

,

i=1,\ldots,m

are the model parameters. The parameters

ai

must be selected so that

Q(p)

is a quantile function.Two four-parametric quantile mixtures, the normal-polynomial quantile mixture and the Cauchy-polynomial quantile mixture, are presented by Karvanen.[16]

Non-linear differential equations for quantile functions

The non-linear ordinary differential equation given for normal distribution is a special case of that available for any quantile function whose second derivative exists. In general the equation for a quantile, Q(p), may be given. It is

d2Q
dp2

=H(Q)\left(

dQ
dp

\right)2

augmented by suitable boundary conditions, where

H(x)=-

f'(x)
f(x)

=-

d
dx

lnf(x)

and ƒ(x) is the probability density function. The forms of this equation, and its classical analysis by series and asymptotic solutions, for the cases of the normal, Student, gamma and beta distributions has been elucidated by Steinbrecher and Shaw (2008). Such solutions provide accurate benchmarks, and in the case of the Student, suitable series for live Monte Carlo use.

See also

Further reading

Notes and References

  1. Ehm . W. . Gneiting . T. . Jordan . A. . Krüger . F. . 2016 . Of quantiles and expectiles: Consistent scoring functions, Choquet representations, and forecast rankings . J. R. Stat. Soc. B . 78 . 3 . 505–562 . 10.1111/rssb.12154 . free. 1503.08195 .
  2. Web site: Archived copy . March 25, 2012 . dead . https://web.archive.org/web/20120324042025/http://course.shufe.edu.cn/jpkc/jrjlx/ref/StaTable.pdf . March 24, 2012 .
  3. Book: Gilchrist, W. . 2000. Statistical Modelling with Quantile Functions. Taylor & Francis . 1-58488-174-7.
  4. Book: Jaeckel, P. . 2002. Monte Carlo methods in finance.
  5. Hörmann . Wolfgang . Leydold . Josef . Continuous random variate generation by fast numerical inversion. ACM Transactions on Modeling and Computer Simulation . 2003 . 13 . 4 . 10.1145/945511.945517. WU Vienna. 17 June 2024. 347-362.
  6. Derflinger. Gerhard. Hörmann. Wolfgang. Leydold. Josef. Random variate generation by numerical inversion when only the density is known. 10.1145/1842722.1842723. 2010. 20. 4. ACM Transactions on Modeling and Computer Simulation. 1-25. Art. No. 18.
  7. Web site: UNU.RAN - Universal Non-Uniform RANdom number generators .
  8. Web site: Runuran: R Interface to the 'UNU.RAN' Random Variate Generators . 17 January 2023 .
  9. Web site: Random Number Generators (Scipy.stats.sampling) — SciPy v1.13.0 Manual .
  10. Book: Baumgarten . Christoph . Patel . Tirth . Automatic random variate generation in Python . Proceedings of the 21st Python in Science Conference . 2022 . 46–51 . 10.25080/majora-212e5952-007. free .
  11. Steinbrecher, G.. Shaw, W.T. . 2008. Quantile mechanics. European Journal of Applied Mathematics. 19. 2. 87–112. 10.1017/S0956792508007341. 6899308 .
  12. Wichura, M.J. . 1988. Algorithm AS241: The Percentage Points of the Normal Distribution. Applied Statistics. 37. 477–484. 10.2307/2347330. 2347330. 3. Blackwell Publishing.
  13. http://home.online.no/~pjacklam/notes/invnorm/ An algorithm for computing the inverse normal cumulative distribution function
  14. https://arxiv.org/abs/0901.0638 Computational Finance: Differential Equations for Monte Carlo Recycling
  15. Shaw, W.T. . 2006. Sampling Student's T distribution – Use of the inverse cumulative distribution function.. Journal of Computational Finance. 9. 4. 37–73. 10.21314/JCF.2006.150 .
  16. Karvanen, J. . 2006. Estimation of quantile mixtures via L-moments and trimmed L-moments.. Computational Statistics & Data Analysis. 51. 2. 947–956. 10.1016/j.csda.2005.09.014.