Quantile


In statistics and probability, quantiles are cut points dividing the range of a probability distribution into continuous intervals with equal probabilities or dividing the observations in a sample in the same way. There is one fewer quantile than the number of groups created. Common quantiles have special names, such as quartiles, deciles, and percentiles. The groups created are termed halves, thirds, quarters, etc., though sometimes the terms for the quantile are used for the groups created, rather than for the cut points.
-'quantiles' are values that partition a finite set of values into subsets of equal sizes. There are partitions of the -quantiles, one for each integer satisfying. In some cases the value of a quantile may not be uniquely determined, as can be the case for the median of a uniform probability distribution on a set of even size. Quantiles can also be applied to continuous distributions, providing a way to generalize rank statistics to continuous variables. When the cumulative distribution function of a random variable is known, the -quantiles are the application of the quantile function to the values.

Quantiles of a population

As in the computation of, for example, standard deviation, the estimation of a quantile depends upon whether one is operating with a statistical population or with a sample drawn from it. For a population, of discrete values or for a continuous population density, the -th -quantile is the data value where the cumulative distribution function crosses. That is, is a -th -quantile for a variable if
and
where is the probability function. For a finite population of equally probable values indexed from lowest to highest, the -th -quantile of this population can equivalently be computed via the value of. If is not an integer, then round up to the next integer to get the appropriate index; the corresponding data value is the -th -quantile. On the other hand, if is an integer then any number from the data value at that index to the data value of the next index can be taken as the quantile, and it is conventional to take the average of those two values.
If, instead of using integers and, the "-quantile" is based on a real number with then replaces in the above formulas. This broader terminology is used when quantiles are used to parameterize continuous probability distributions. Moreover, some software programs regard the minimum and maximum as the 0th and 100th percentile, respectively. However, this broader terminology is an extension beyond traditional statistics definitions.

Examples

The following two examples use the Nearest Rank definition of quantile with rounding. For an explanation of this definition, see percentiles.

Even-sized population

Consider an ordered population of 10 data values . What are the 4-quantiles of this dataset?
QuartileCalculationResult
Zeroth quartileAlthough not universally accepted, one can also speak of the zeroth quartile. This is the minimum value of the set, so the zeroth quartile in this example would be 3.3
First quartileThe rank of the first quartile is 10× = 2.5, which rounds up to 3, meaning that 3 is the rank in the population at which approximately 1/4 of the values are less than the value of the first quartile. The third value in the population is 7.7
Second quartileThe rank of the second quartile is 10× = 5, which is an integer, while the number of values is an even number, so the average of both the fifth and sixth values is taken—that is /2 = 9, though any value from 8 through to 10 could be taken to be the median.9
Third quartileThe rank of the third quartile is 10× = 7.5, which rounds up to 8. The eighth value in the population is 15.15
Fourth quartileAlthough not universally accepted, one can also speak of the fourth quartile. This is the maximum value of the set, so the fourth quartile in this example would be 20. Under the Nearest Rank definition of quantile, the rank of the fourth quartile is the rank of the biggest number, so the rank of the fourth quartile would be 10.20

So the first, second and third 4-quantiles of the dataset are . If also required, the zeroth quartile is 3 and the fourth quartile is 20.

Odd-sized population

Consider an ordered population of 11 data values . What are the 4-quantiles of this dataset?
QuartileCalculationResult
Zeroth quartileAlthough not universally accepted, one can also speak of the zeroth quartile. This is the minimum value of the set, so the zeroth quartile in this example would be 3.3
First quartileThe first quartile is determined by 11× = 2.75, which rounds up to 3, meaning that 3 is the rank in the population at which approximately 1/4 of the values are less than the value of the first quartile. The third value in the population is 7.7
Second quartileThe second quartile value is determined by 11× = 5.5, which rounds up to 6. Therefore, 6 is the rank in the population at which approximately 2/4 of the values are less than the value of the second quartile. The sixth value in the population is 9.9
Third quartileThe third quartile value for the original example above is determined by 11× = 8.25, which rounds up to 9. The ninth value in the population is 15.15
Fourth quartileAlthough not universally accepted, one can also speak of the fourth quartile. This is the maximum value of the set, so the fourth quartile in this example would be 20. Under the Nearest Rank definition of quantile, the rank of the fourth quartile is the rank of the biggest number, so the rank of the fourth quartile would be 11.20

So the first, second and third 4-quantiles of the dataset are . If also required, the zeroth quartile is 3 and the fourth quartile is 20.

Relationship to the mean

For any population probability distribution on finitely many values, and generally for any probability distribution with a mean and variance, it is the case that
where is the value of the -quantile for , where is the distribution's arithmetic mean, and where is the distribution's standard deviation. In particular, the median is never more than one standard deviation from the mean.
The above formula can be used to bound the value in terms of quantiles.
When, the value that is standard deviations above the mean has a lower bound
For example, the value that is standard deviation above the mean is always greater than or equal to, the median, and the value that is standard deviations above the mean is always greater than or equal to, the fourth quintile.
When, there is instead an upper bound
For example, the value for will never exceed, the first decile.

Estimating quantiles from a sample

One problem which frequently arises is estimating a quantile of a population based on a finite sample of size.
Modern statistical packages rely on a number of techniques to estimate the quantiles.
Hyndman and Fan compiled a taxonomy of nine algorithms used by various software packages.
All methods compute, the estimate for the -quantile from a sample of size by computing a real valued index. When is an integer, the -th smallest of the values,, is the quantile estimate. Otherwise a rounding or interpolation scheme is used to compute the quantile estimate from,, and. .
The first three are piecewise constant, changing abruptly at each data point, while the last six use linear interpolation between data points, and differ only in how the index used to choose the point along the piecewise linear interpolation curve, is chosen.
Mathematica, Matlab, R and GNU Octave programming languages support all nine sample quantile methods. SAS includes five sample quantile methods, SciPy and Maple both include eight, EViews and Julia include the six piecewise linear functions, Stata includes two, Python includes two, and Microsoft Excel includes two. Mathematica, SciPy and Julia support arbitrary parameters for methods which allow for other, non-standard, methods.
The estimate types and interpolation schemes used include:
TypeNotes
R‑1, SAS‑3, Maple‑1Inverse of empirical distribution function.
R‑2, SAS‑5, Maple‑2, StataThe same as R-1, but with averaging at discontinuities.
R‑3, SAS‑2The observation numbered closest to. Here, indicates rounding to the nearest integer, choosing the even integer in the case of a tie.
R‑4, SAS‑1, SciPy‑, Julia‑, Maple‑3Linear interpolation of the inverse of the empirical distribution function.
R‑5, SciPy‑, Julia‑, Maple‑4Piecewise linear function where the knots are the values midway through the steps of the empirical distribution function.
R‑6, Excel, Python, SAS‑4, SciPy‑, Julia-, Maple‑5, Stata‑altdefLinear interpolation of the expectations for the order statistics for the uniform distribution on . That is, it is the linear interpolation between points, where is the probability that the last of randomly drawn values will not exceed the -th smallest of the first randomly drawn values.
R‑7, Excel, Python, SciPy‑, Julia-, Maple‑6, NumPyLinear interpolation of the modes for the order statistics for the uniform distribution on .
R‑8, SciPy‑, Julia‑, Maple‑7Linear interpolation of the approximate medians for order statistics.
R‑9, SciPy‑, Julia‑, Maple‑8The resulting quantile estimates are approximately unbiased for the expected order statistics if is normally distributed.

Notes:
  • R‑1 through R‑3 are piecewise constant, with discontinuities.
  • R‑4 and following are piecewise linear, without discontinuities, but differ in how is computed.
  • R‑3 and R‑4 are not symmetric in that they do not give when.
  • Excel's PERCENTILE.EXC and Python's default "exclusive" method are equivalent to R‑6.
  • Excel's PERCENTILE and PERCENTILE.INC and Python's optional "inclusive" method are equivalent to R‑7. This is R's and Julia's default method.
  • Packages differ in how they estimate quantiles beyond the lowest and highest values in the sample, i.e. and. Choices include returning an error value, computing linear extrapolation, or assuming a constant value.
Of the techniques, Hyndman and Fan recommend R-8, but most statistical software packages have chosen R-6 or R-7 as the default.
The standard error of a quantile estimate can in general be estimated via the bootstrap. The Maritz–Jarrett method can also be used.