Quantiles and Percentiles

Cut a distribution into equal-sized groups. The box plot is what you get when you draw the cuts.

Overview

The definition

The q-th quantile is the value below which a fraction q of the data falls. The 0.5 quantile is the median: half below, half above. The 0.9 quantile is the value 90% of the data sits below.

Percentiles are the same idea on a 0–100 scale — the 90th percentile is the 0.9 quantile. Quartiles cut at 25, 50 and 75, dividing the data into four equal groups. Deciles cut into ten.

Quantiles and Percentiles

This module needs JavaScript: the numbers are computed in the page rather than recorded.

Worth knowing

The q-th quantile is the value below which a fraction q of the data falls. The median is q = 0.5.
Percentiles are the same thing on a 0-100 scale. Quartiles cut at 25, 50 and 75.
The IQR is Q3 − Q1: the range covering the middle half, and a spread measure that ignores outliers entirely.
Whiskers reach the furthest points within 1.5 IQR of the box. Anything beyond is drawn individually — a convention, not a test.

Quantiles and Percentiles

Describing a distribution by where its values sit rather than by averaging them.

Why not just use the mean

A mean is a balance point, and it moves when anything moves. A quantile depends only on order, and that makes it robust.

Add a single enormous value to a dataset and the mean shifts, possibly a lot. The median barely moves at all — the new value is simply "one more above the middle", regardless of how far above.

That is why median income is reported rather than mean income, why latency is reported at percentiles, and why the [box plot](#) below exists.

The IQR — Q3 minus Q1 — is the spread measure that follows from the same idea. It covers the middle half of the data, and it is unaffected by anything in the tails. Standard deviation, being built from squared distances from the mean, is the opposite: one extreme value moves it substantially.

Reading the box plot

The second panel is assembled from the quartiles in the first, and every part of it has a definition:

The box spans Q1 to Q3, so it contains the middle 50% of the data.

The line inside is the median. Its position within the box shows skew: off centre means the distribution leans.

The whiskers reach the furthest data points still within 1.5 × IQR of the box edge.

The dots are everything beyond that.

The 1.5 is a convention, not a test. It comes from Tukey, and for a normal distribution it flags about 0.7% of points. Points beyond it are worth inspecting, and calling them "outliers" makes a claim the rule cannot support — a skewed distribution produces them by construction rather than by error.

Increase the sample size and the number of flagged points grows roughly in proportion. That alone shows the rule is descriptive.

Percentiles in practice

Latency. Nobody reports mean response time, because one slow request buried in a million is invisible in a mean and obvious at p99. Services are specified at p50, p95, p99 and p999 precisely because the tail is what users notice.

A trap follows immediately: percentiles do not average. The p99 of two servers is not the mean of their p99s. Aggregating percentiles requires the underlying distributions or a structure like a t-digest.

Quantile regression predicts a chosen quantile rather than the mean. Useful when the cost of over- and under-prediction differ, or when you want a prediction interval directly.

Quantile binning turns a continuous feature into equal-sized buckets, which is robust to skew in a way that equal-width binning is not.

Feature scaling. QuantileTransformer maps a feature to a uniform or normal distribution through its quantiles, and is unaffected by outliers in a way standardisation is not.

A wrinkle worth knowing

There is no single agreed definition of a sample quantile. With 10 data points, "the value below which 25% falls" does not land on an observation, and there are several defensible interpolations. NumPy offers nine methods; R offers the same nine; the defaults differ between languages, and between numpy.percentile and some SQL engines.

For large samples the differences are negligible. For small ones they are not, and two tools can legitimately report different quartiles for identical data.

Where it goes wrong

Averaging percentiles. The single most common error, and it always understates the tail.

Reading whisker points as errors. The rule is a drawing convention.

Comparing box plots of very different sample sizes. More data means more flagged points, mechanically.

Assuming your language's default matches another's. State the method when it matters.

Check yourself

0 of 3

Answer without scrolling back up.

  1. Why is the median unaffected by adding one enormous value?

  2. What do the whiskers on a box plot reach?

  3. Why can you not average the p99 of two servers?

Cheat sheet

Quantiles and Percentiles

The q-th quantile is the value below which a fraction q of the data falls. The 0.5 quantile is the median: half below, half above. The 0.9 quantile is the value 90% of the data sits below.

MATHS · vizlearn.in/maths/quantiles_and_percentiles.html

About the author

Ashish Jangra builds and maintains VizLearn. Every module here is written and the visualisation behind it hand-built, so the numbers in a readout come from the same code that draws the picture. Corrections are genuinely welcome and get priority over everything else — if a page states something wrong, or an animation misrepresents what the algorithm does, get in touch.