Percentiles and Quartiles Explained

โฑ๏ธ 35 sec read ๐Ÿ“ˆ Data Analysis

The Nth percentile is the value below which N% of your data falls: p50 is the median, and p95 means 95% of observations are at or below that value. Quartiles are just the 25th, 50th, and 75th percentiles.

What Do p50 and p95 Actually Mean?

p50 (the median) is the typical experience โ€” half of observations are faster, half slower โ€” while p95 describes the worst experience 1 in 20 observations gets.

import numpy as np

latency_ms = np.array([80, 95, 100, 110, 120, 130, 150, 180, 400, 2500])

np.percentile(latency_ms, 50)   # 125.0  โ†’ typical request
np.percentile(latency_ms, 95)   # 1555.0 โ†’ tail experience
latency_ms.mean()               # 386.5  โ†’ matches nobody

Note the mean (386 ms) is slower than 8 of the 10 requests โ€” two slow outliers dragged it into territory that describes no real user.

What Are Quartiles and the IQR?

Quartiles split sorted data into four equal parts: Q1 = p25, Q2 = p50, Q3 = p75, and the interquartile range IQR = Q3 โˆ’ Q1 measures the spread of the middle 50%.

q1, q3 = np.percentile(latency_ms, [25, 75])
iqr = q3 - q1

# Standard outlier fences (what box plots use):
lower = q1 - 1.5 * iqr
upper = q3 + 1.5 * iqr
latency_ms[(latency_ms < lower) | (latency_ms > upper)]
# array([ 400, 2500])

Because quartiles ignore the extreme tails, the IQR outlier rule stays sane even when the outliers themselves are enormous.

Why Do Percentiles Beat Averages for Latency and Skewed Data?

Averages are pulled toward extreme values, so on right-skewed data like latency, revenue, or file sizes, the mean describes almost no one; percentiles are robust and map directly to user experience.

# "Average latency is 200ms" can hide this:
# p50 = 90ms   (most users are fine)
# p99 = 8000ms (1% of requests are awful)

# SLOs are therefore written in percentiles:
# "p95 < 500ms" = 95% of requests complete in under 500ms

The mean still has a place โ€” capacity planning and total-cost math need it because totals are means times counts. For a refresher on when each center measure applies, see mean vs. median vs. mode.

Common Pitfalls

Pro Tip: When someone reports an average of skewed data, ask for the p50 and p95 too. If the mean sits far above the median, the distribution has a heavy tail and every "average" claim about it deserves a second look.

โ† Back to Data Analysis Tips