Mean, Median, and Percentiles, From First Principles
34 minutes read •
This write-up was distilled from a real session reading a build dashboard: three numbers — mean 11.2 min, P50 8.35 min, P90 19.8 min — and one question, do these even make sense? The document below builds every concept needed to answer it from the ground up: what a mean and a median actually measure, why latency is always uneven, what percentiles add, and how to sanity-check a set of summary numbers in seconds. Prerequisites: you can add and divide. Nothing more is assumed.
Part 1 — Two ways to summarize a list of numbers
You have many measurements — build durations, request latencies, page loads — and you want one number that says "this is what's typical". There are two common choices, and they answer subtly different questions.
Mean (the average)
The arithmetic mean of n values is
Every point enters the sum, which is its weakness: a single large xi shifts x̄ by Δxi / n. The mean is the distribution's center of mass.
Median (the middle, a.k.a. P50)
Sort the values x(1) ≤ x(2) ≤ … ≤ x(n); the median is the middle order statistic:
It depends only on position, not magnitude — so a single huge value barely moves it.
The example that shows the difference
Five builds finish in x = (6, 7, 8, 9, 40) minutes (one was a cold-cache straggler):
Four of five builds finished under 10 minutes, yet x̄ = 14 — the lone 40 dragged it up, while x̃ = 8 stayed put. The mean is sensitive to outliers; the median is robust to them.
x̄ > x̃ ⟺ long tail on the high side (right skew)
The gap measures the pull. Our build numbers give x̄ − x̃ = 11.2 − 8.35 = 2.85 min, a ratio of x̄ / x̃ = 11.2 / 8.35 ≈ 1.34 — a slow minority pulling the mean ~34% above the median. The normal signature of timing data (Part 2).
Part 2 — Why latency is (almost) always uneven
Build times, request times, any "how long did it take" metric share a structural property: they are right-skewed — a tall cluster of fast results with a long tail trailing off to the right.
There is a floor, but no ceiling
A build can't take less than zero time, and in practice not less than some minimum (compile the world, link, etc.). But it can take arbitrarily long: a cold cache, a busy machine, a flaky network download, a retry. The fast side is bounded; the slow side is open-ended. That asymmetry is the skew.
Consequence: x̄ ≥ x̃, by default
The high-side tail pulls the center-of-mass while the middle position holds, so for healthy latency you should expect
It is not a defect to fix — it is the shape of the phenomenon.
A hard floor on the left, an open-ended tail on the right: that asymmetry is the right-skew, and it is what pushes the mean to the right of the median.
Part 3 — Percentiles: P50, P90, P99
A percentile answers one plain question: compared to everything else, how far up the list is this? Sort your builds from fastest to slowest — P90 is the point that 90% of builds come in under. Only the slowest 10% take longer.
Make it concrete. Here are five build times, in the order they finished: 8, 5, 19, 6, 9 minutes. Line them up fastest → slowest:
- The middle value is 8 — that is the median, also called P50. Half the builds are faster, half are slower. The "typical" build.
- The average is (5+6+8+9+19) ÷ 5 = 9.4 — bigger than the median, because the one slow 19 drags it up. That gap between 9.4 and 8 is exactly the problem with averages from Part 1.
- P90 is the same move, but at 90% instead of 50%: walk up the sorted list until you have passed 90% of the builds. With lots of data it is "the line that 9 out of 10 builds beat" — it lives out in the slow tail.
Now imagine doing this for hundreds of builds. Walk left → right through every build time, and each time you pass one build, step up a little. The height at any point is just "what fraction of builds have I passed so far?" — that rising staircase is the picture below. To read any percentile, find its height on the left, slide across to the steps, and drop down to the time.
Each build nudges the line up one step. To find P90: start at 90% on the left, slide across to the staircase, then drop to the time below it. P50 is the median; P90 and P99 sit further out in the slow tail. Let F(x) be the fraction of samples at or below x — exactly the height of the staircase above. Then the k-th percentile is the smallest x whose height has reached k/100: "inf" just means "the smallest value that qualifies" — it only matters for the flat parts of the staircase, where many x share the same height.The same idea, written as a formula
P50 — the typical case
Half of builds are faster than this. The everyday experience. Same thing as the median.
P90 — the "bad day"
9 of every 10 builds beat this; the slowest 10% are worse. This is the number that captures "sometimes it just takes forever" without being thrown off by the single worst outlier.
P99 — the worst-case-ish
Only 1 in 100 is slower. Matters when rare slowness is expensive (CI queues, user-facing requests at scale). Not in our three numbers, but worth requesting.
Part 4 — The shape, drawn
Here is the distribution of build durations. Toggle between a hypothetical symmetric dataset and the skewed one our real numbers describe, and watch the three markers move relative to each other.
Right-skewed: a tall cluster of fast builds and a long tail. The mean (yellow) is dragged right of the median (blue) by that tail; P90 (red) sits far out in it.
Part 5 — Sanity-checking a set of numbers
Back to the original question: do mean 11.2, P50 8.35, P90 19.8 make sense? Two quick checks settle it.
Ordering check passes
For right-skewed latency the only sensible order is P50 < x̄ < P90. Ours:
x̄ above the median is the expected fingerprint of skew (Part 2). Had x̄ < 8.35, that would be the red flag worth chasing.
Tail check worth a look
Two dimensionless ratios gauge how uneven the data is:
The slowest 10% take well over double a typical build. Both ratios sit in the normal range (most real systems land 2–4×), but the tail is where time is actually lost.
Verdict: the numbers are internally consistent and realistic. They describe an ordinary, healthy distribution — most builds near 8 minutes, an average nudged to ~11 by a slow minority, a "bad day" near 20.
The one thing to act on is that 8 → 20 minute tail, not the headline average.
Part 6 — Which number to use when
| Number | Use it for | Why |
|---|---|---|
| P50 | Headline "how fast are builds" / daily developer experience | Reflects the common case, immune to rare outliers. |
| P90 / P95 | SLOs, alerting thresholds, "worst-case" budgeting | Catches tail regressions before they become "builds randomly hang" complaints. |
| P99 / max | Rare-but-expensive slowness at scale | The true worst case lives past P90; request it when the tail is costly. |
| Mean | Almost nothing, on its own | One 60-min build moves it without telling you whether the typical case or the tail changed. Useful only paired with the median as a skew signal. |
Part 7 — Things people get wrong
"I'll just average the percentiles to combine two services."
First, what "combine" means here: you have build times measured separately for two things — say a Linux runner pool and a macOS pool, or the app and core targets in a monorepo — and you want one P90 across both. The tempting shortcut is to average the two P90s your dashboard already shows. It doesn't work, because a percentile is a position in the sorted data, not a quantity you can add or average.
Counterexample: pool A is ten builds all at 2 min (so P90 = 2), pool B is ten builds at 10 min (P90 = 10). Averaging the two gives 6 min — but dump all 20 builds into one pile and the real combined P90 is 10 min. Build volume tips it further: if core builds 2,000×/day and app builds 10×/day, the combined P90 is essentially core's — one pool dominates the pile, so averaging the two numbers as equals is meaningless.
You also can't recover the mean x̄ from P50 and P90: those say nothing about the top 10%, where the mean's weight sits. Two pools with the same P50 and P90 can have wildly different averages — one's slowest builds might top out at 25 min, another's drag out to hours.
Each percentile is its own independent cut of the data. To combine pools or projects, go back to the raw build durations (pool them and recompute), or keep a mergeable summary per pool like a histogram or t-digest and merge those before reading the percentile — never do arithmetic on the finished P90 numbers.
"Mean and median are basically the same thing."
Only for symmetric data (toggle the chart in Part 4 to see them coincide). For anything with a tail — which is all latency — they diverge, and the gap is information: it tells you how skewed the data is.
"A 2.37× P90/P50 ratio looks bad."
It's typical, not bad. Build and request systems commonly sit between 2× and 4×. A ratio drifting toward 5×+ signals an unstable tail worth investigating; a ratio near 1× would mean unusually consistent timing. 2.37× is normal variability with clear room to tighten.
"These three numbers are enough."
Three things are missing: the sample count and time window (11.2 min over 50 builds is far less trustworthy than over 50,000), the P99 / max (the real worst case lives past P90), and a trend over time (a single snapshot can't say whether builds are getting faster or slower).
Glossary
- mean (average)
- x̄ = (1/n) Σi xi. Uses every point; sensitive to outliers. The distribution's center of mass.
- median (P50)
- x̃ = P50, the middle order statistic of the sorted data — half below, half above. Robust to outliers.
- percentile (Pk)
- Pk = inf{ x : F(x) ≥ k/100 }, the value below which k% of measurements fall. P50 is the median.
- right-skew
- A distribution with a long high-side tail and a low-side bound. Produces x̄ > x̃. The natural shape of latency data.
- tail
- The slow minority of measurements (e.g. the slowest 10%, captured by P90). Where most "it's sometimes slow" pain lives.
- SLO
- Service Level Objective — a target almost always written on a percentile (e.g. P95 < 15 min) because percentiles are robust to single outliers.
- spread / skew ratio
- P90/P50 measures tail spread; x̄/P50 measures skew. Quick gauges of how uneven a distribution is.
Summary
The mean is a balance point and moves with every outlier; the median and other percentiles are positions and ignore magnitude. Latency data has a floor but no ceiling, so it is right-skewed, so its mean sits above its median by default. To sanity-check a set of summary numbers, confirm the ordering (P50 < Mean < P90 for skewed data) and read the gaps as skew. Make decisions on percentiles; keep the mean only as a companion that reveals skew.
Build numbers verified consistent: P50 8.35 · Mean 11.2 · P90 19.8 min · June 2026