What a percentile is
The P-th percentile is the value below which P percent of the data fall. If the 90th percentile of your response times is 275 ms, then 90% of requests completed in 275 ms or less and 10% took longer. That is the whole idea, and it is why percentiles dominate anywhere the tail matters more than the average: service level agreements, growth charts, standardised test scores, salary bands and latency dashboards.
Percentiles describe position, not distance. Moving the slowest request from 410 ms to 4,100 ms does not change the 90th percentile at all, because the observation stays in the same place in the order. That resistance is the reason a P95 latency figure is far more informative than a mean latency figure: the mean is dragged around by a handful of pathological requests, while the percentile tells you what a user at a specific point in the distribution actually experiences.
Quartiles are percentiles with familiar names. Q1 is the 25th percentile, the median is the 50th, and Q3 is the 75th; their difference is the interquartile range. Deciles cut at every 10th percentile and quintiles at every 20th, which is how income distributions are usually reported.
Rank, interpolation, and why three methods exist
Every percentile calculation has two steps. First convert the requested percentage into a rank - a position in the sorted data. Then read the value at that position, interpolating if the position is not a whole number.
The awkwardness is in step one, because n observations divide the number line into more than n regions, so there is no single obviously correct mapping from a percentage to a position. Three answers are in general use.
- Inclusive interpolation, L = 1 + (n - 1)P/100. The smallest observation is the 0th percentile and the largest is the 100th, with everything spread evenly between. This is Excel's PERCENTILE.INC, R's type 7 default and NumPy's default, so it is what most people get without choosing.
- Exclusive interpolation, L = (n + 1)P/100. Treats the sample as if it came from a larger population in which observations sit at positions 1/(n+1), 2/(n+1) and so on. It cannot resolve percentiles below 1/(n+1) or above n/(n+1) - with ten observations, nothing below the 9.09th or above the 90.91st - and Excel's PERCENTILE.EXC returns an error there. This is R's type 6.
- Nearest rank, L = ceiling(n x P/100). No interpolation at all: round the rank up and return that observation. The answer is always a value that genuinely occurred, which is why many service level agreements are written this way.
Once the rank is fixed, interpolation is straightforward. If L = 9.1, take the 9th sorted value, add 0.1 of the gap to the 10th, and that is your answer. The quartile calculator offers the same choice in the specific case of the 25th and 75th percentiles.
Hyndman and Fan's 1996 review catalogues nine distinct sample quantile definitions used in statistical software. The three here cover almost everything you will meet in practice, but the lesson of that paper stands: state which definition you used.
Worked example: the 90th percentile of ten response times
Ten requests are timed, in milliseconds: 120, 135, 128, 410, 142, 133, 150, 129, 138, 260.
- Sort them. 120, 128, 129, 133, 135, 138, 142, 150, 260, 410. So n = 10.
- Convert the percentile to a proportion. P = 90, so p = 0.90.
- Find the rank, inclusive method. L = 1 + (10 - 1) x 0.90 = 1 + 8.1 = 9.1.
- Identify the neighbours. The 9th sorted value is 260 and the 10th is 410.
- Interpolate. The fractional part of the rank is 0.1, so the answer is 260 + 0.1 x (410 - 260) = 260 + 15 = 275 ms.
Now do the same with nearest rank. L = ceiling(10 x 0.90) = ceiling(9) = 9, so the answer is the 9th sorted value, 260 ms. And with the exclusive method, L = 11 x 0.90 = 9.9, giving 260 + 0.9 x 150 = 395 ms.
Three defensible methods, three answers spanning 135 ms on the same ten numbers. That spread is not a defect of the arithmetic; it is what happens when you ask ten observations to locate a point that only about one observation lies beyond. If this were an SLA, the difference between promising 260 ms and promising 395 ms would be a commercial decision, and the contract needs to say which definition applies.
For comparison, the mean of these ten values is 1,745 / 10 = 174.5 ms - lower than every one of the three percentile answers, because two slow requests pull it up while eight fast ones hold it down. The mean answers "what is the total time divided by the count"; the percentile answers "how slow is a slow request".
Reading a percentile, and how much data you need
Read a percentile as a promise about position. The 95th percentile is the value that 95% of observations do not exceed; equivalently, 1 in 20 observations exceeds it. That reciprocal is the useful mental conversion: P90 means 1 in 10, P95 means 1 in 20, P99 means 1 in 100, P99.9 means 1 in 1,000.
It follows immediately that you cannot measure a percentile more extreme than your sample supports. With 10 observations, a single value covers 10 percentage points of the distribution, so a 99th percentile is not measured - it is the maximum with a label on it. As a working rule you want on the order of 100 observations before quoting a 99th percentile and 1,000 before a 99.9th, and even then the estimate moves substantially from sample to sample because it rests on the handful of most extreme points.
Central percentiles are far better behaved. The median is the most stable percentile in any data set, and the quartiles are close behind. If your sample is small, quote the median and quartiles and say nothing about the tail.
Two properties are worth keeping in mind when comparing groups. Percentiles are invariant under any strictly increasing transformation - the 90th percentile of the logarithms is the logarithm of the 90th percentile - which makes them convenient for skewed data. But percentiles do not add: the 95th percentile of a sum of two latencies is not the sum of their 95th percentiles, and averaging the P95 figures of several servers does not give the P95 of the whole fleet. To get that, pool the raw observations and recompute.
How the three methods differ on the integers 1 to 10
| Percentile | Inclusive rank | Inclusive value | Exclusive rank | Exclusive value | Nearest rank value |
|---|---|---|---|---|---|
| 10th | 1.90 | 1.90 | 1.10 | 1.10 | 1 |
| 25th | 3.25 | 3.25 | 2.75 | 2.75 | 3 |
| 50th | 5.50 | 5.50 | 5.50 | 5.50 | 5 |
| 75th | 7.75 | 7.75 | 8.25 | 8.25 | 8 |
| 90th | 9.10 | 9.10 | 9.90 | 9.90 | 9 |
| 95th | 9.55 | 9.55 | 10.45 | undefined | 10 |
On evenly spaced data the interpolated value happens to equal the rank, which makes the pattern easy to see. The two interpolating methods agree at the median; nearest rank does not, because it returns the 5th sorted value rather than the average of the 5th and 6th. All three diverge steadily as you move into the tails.
Traps to avoid
- Averaging percentiles. The mean of four servers' P95 latencies is not the fleet P95. Percentiles are order statistics and do not combine linearly. Pool the raw data and recompute.
- Not stating the method. On a small sample the three definitions can differ by a whole observation. Any SLA, report or comparison that quotes a percentile without saying how it was computed is under-specified.
- Quoting a percentile the sample cannot support. A P99 from 50 observations is the maximum wearing a label. Check that at least a few observations lie beyond the point you are quoting.
- Confusing percentile with percentage. Scoring in the 80th percentile on a test does not mean scoring 80%. It means outscoring 80% of the other candidates, which could correspond to any raw mark at all.
- Assuming percentiles are equally spaced. The gap between P50 and P60 is usually far smaller than the gap between P90 and P99, because data thin out in the tails. A ten-point move in percentile is not a fixed move in value.
- Interpolating on discrete or categorical data. If the values are counts of defects or scores on a five-point scale, an interpolated percentile of 3.25 is not a possible observation. Use the nearest-rank method there.
Percentiles alongside the other summaries
A percentile locates one point in a distribution you already have. A z-score does something different: it locates a point relative to a mean and a standard deviation, and then converts to a percentile only if you are willing to assume a normal distribution. On raw empirical data the percentile calculator makes no distributional assumption at all, which is why it is the right tool for latencies, incomes and any other visibly skewed measurement.
The 25th, 50th and 75th percentiles together form the box of a box plot, and the IQR calculator adds the 1.5 x IQR fences that determine the whiskers. For a single figure describing the centre, the median is the 50th percentile by another name, and the standard deviation describes spread by distance where the IQR describes it by position.
When you do have a fitted distribution rather than raw data, percentiles come from the inverse cumulative function instead of from a rank. For a normal model, the inverse normal calculator converts a percentile directly into a z value and then into a raw score, and the normal distribution calculator goes the other way. Those tools extrapolate into the far tail where raw data run out; whether that extrapolation is trustworthy depends entirely on whether the normal model actually fits, which for latency data it almost never does.
