Quantile

Quantile[list, q]
gives the ^(th) quantile of list.

Quantile[list, {q1, q2, ...}]
gives a list of quantiles , , ....

Quantile[list, q, {{a, b}, {c, d}}]
uses the quantile definition specified by parameters a, b, c, d.

Quantile[dist, q]
gives a quantile of the symbolic distribution dist.

DetailsDetails

  • Quantile is also known as value at risk (VaR) or fractile.
  • Quantile[list, q] gives Sort[list, Less][[Ceiling[qLength[list]]]].
  • Quantile[{{x1, y1, ...}, {x2, y2, ...}, ...}, q] gives .
  • For a list of length n, Quantile[list, q, {{a, b}, {c, d}}] depends on . If x is an integer, the result is , where s=Sort[list, Less]. Otherwise the result is s[[Floor[x]]]+(s[[Ceiling[x]]]-s[[Floor[x]]])(c+dFractionalPart[x]), with the indices taken to be 1 or n if they are out of range.
  • The default choice of parameters is .
  • Common choices of parameters include:
  • {{0, 0}, {1, 0}}inverse empirical CDF (default)
    {{0, 0}, {0, 1}}linear interpolation (California method)
    {{1/2, 0}, {0, 0}}element numbered closest to
    {{1/2, 0}, {0, 1}}linear interpolation (hydrologist method)
    {{0, 1}, {0, 1}}mean-based estimate (Weibull method)
    {{1, -1}, {0, 1}}mode-based estimate
    {{1/3, 1/3}, {0, 1}}median-based estimate
    {{3/8, 1/4}, {0, 1}}normal distribution estimate
  • Quantile[list, q] always gives a result equal to an element of list.
  • The same is true whenever d is .
  • When d is , Quantile is piecewise linear as a function of q.
  • Median[list] is equivalent to Quantile[list, 1/2, {{1/2, 0}, {0, 1}}].
  • About 10 different choices of parameters are in use in statistical work.
  • Quantile works with SparseArray objects.
  • Quantile[dist, q] is equivalent to InverseCDF[dist, q].

ExamplesExamplesopen allclose all

Basic Examples (6)Basic Examples (6)

Find the halfway value (median) of a list:

In[1]:=
Click for copyable input
Out[1]=

Find the quarter-way value (lower quartile) of a list:

In[1]:=
Click for copyable input
Out[1]=

Lower and upper quartiles:

In[1]:=
Click for copyable input
Out[1]=

The q^(th) quantile for a normal distribution:

In[1]:=
Click for copyable input
Out[1]=

Quantile function for a continuous univariate distribution:

In[1]:=
Click for copyable input
Out[1]=

Quantile function for a discrete univariate distribution:

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=
New in 5 | Last modified in 6
New to Mathematica? Find your learning path »
Have a question? Ask support »