Quantiles explained: sample calculations and software differences
A quantile is a value that marks a chosen cumulative share of ordered data. This guide works through sample calculations, explains why software can differ, and shows what to report.
A quantile is a value that marks a chosen cumulative share of a distribution. The 90th percentile, for example, is a threshold at or below which roughly 90% of the reference observations lie, under a stated definition. It does not mean that 90% of an exam was answered correctly. For a finite sample, software may return different values because it uses different rank and interpolation rules.
What part of a distribution does a quantile describe?
The cumulative distribution function F(x) is the probability that a value is at or below x. A population p-quantile is the boundary where the cumulative share reaches p, with p between 0 and 1. Thus p=.25 is the 25% point and p=.90 is the 90% point. In a discrete distribution, cumulative probability can jump over p, so there may be no value with exactly that share; the generalized inverse of the distribution supplies a useful threshold definition.
Quartiles are the three cut points associated with .25, .50, and .75. The middle cut point, Q2, corresponds to the median. Percentiles use hundredths of the distribution, and deciles use tenths. These are names for the same cumulative-location idea. With ties or different sample estimators, the numbers of observations on each side need not split into exactly equal groups. OpenStax explains quartiles and percentiles as locations in ordered data: https://openstax.org/books/introductory-statistics-2e/pages/2-3-measures-of-the-location-of-the-data
Why can a sample calculation differ?
Sort the sample from smallest to largest and label the ordered values x(1), x(2), …, x(n). A sample quantile can select an order statistic or interpolate between neighboring values. Sorting alone does not choose a unique convention.
Consider illustrative processing times of 2, 4, 7, 9, 12, 20, 28, and 40 minutes (n=8). For p=.25, the inverse empirical distribution rule selects rank ceil(np)=ceil(2)=2, so the result is 4 minutes. Under R’s default type 7, h=1+(n−1)p=2.75; interpolate 75% of the way from 4 to 7, giving 4+.75×3=6.25 minutes. R documents nine sample-quantile algorithms and uses type 7 by default: https://stat.ethz.ch/R-manual/R-devel/library/stats/html/quantile.html
Another linear rule, R type 6, uses h=(n+1)p=2.25, giving 4+.25×3=4.75 minutes. The results 4, 4.75, and 6.25 are not arithmetic mistakes; they follow different conventions for estimating a quantile between ranks. Hyndman and Fan compared multiple definitions used in statistical packages and described their differing properties: https://mail.robjhyndman.com/publications/quantiles/
Differences can be more noticeable in small samples or near the tails. A larger sample often makes neighboring observations closer, but does not make every method identical. NIST also documents a piecewise-linear empirical quantile function based on ordered data: https://www.itl.nist.gov/div898/software/dataplot/refman2/auxillar/empqua.htm
A reproducible workflow
Define the probability p and the reference group. “The 90th percentile of completed deliveries this quarter” needs a population, period, unit, and inclusion rule.
Record how missing values and duplicates are handled. A repeated delivery may be a real observation rather than an error. If survey weights apply, select a weighted-quantile definition instead of assuming an ordinary unweighted formula is appropriate.
Sort the eligible values and check the software documentation for its default method or type option. Record the function, algorithm setting, and software version.
Verify a rank-based result against the selected order statistic. For interpolation, check the two neighboring values and fraction used. Round only after calculation.
Report p, the estimated value and unit, sample size, reference group and period, missing-value and weighting treatment, software, and quantile method.
Interpret the threshold carefully
A quantile value answers, “What measurement marks this cumulative share?” A percentile rank answers, “What share of the reference data is at or below this observed value?” Confusing the two can reverse an operational claim. For example, a 90th-percentile delivery time is a time threshold; a particular order’s percentile rank is its location in the distribution.
The share at or below a sample quantile is not guaranteed to equal p exactly. Ties, sample size, and the estimator rule affect it. Interpolation can produce a value that was never observed; this is an estimated boundary between ranks, not a newly measured case. If the boundary must be an observed value, specify a rank-based definition. A 90th percentile also describes the stated reference data, not a promise about every future user or period.
Quantiles describe location, not cause. A high tail quantile can be sensitive to a few observations, and small samples make tail estimates uncertain. If that uncertainty matters, examine an interval or resampling sensitivity. Report an illustrative service threshold as hypothetical; for example, “The 90th percentile was 10 minutes under R 4.6.0 type 7” must not be presented as an actual measurement unless real data support it. Include the denominator and period when using a threshold for an SLA.
In short, a quantile turns a cumulative share into a value boundary. To make the result reproducible, define the comparison group and p, name the sample algorithm, and distinguish the threshold value from the share of observations below it.
References: OpenStax, location measures — https://openstax.org/books/introductory-statistics-2e/pages/2-3-measures-of-the-location-of-the-data ; R Documentation, Sample Quantiles — https://stat.ethz.ch/R-manual/R-devel/library/stats/html/quantile.html ; Hyndman and Fan, Sample quantiles in statistical packages — https://mail.robjhyndman.com/publications/quantiles/ ; NIST, Empirical Quantile Function — https://www.itl.nist.gov/div898/software/dataplot/refman2/auxillar/empqua.htm