Five-Number Summary
Descriptive Statistics
Five Numbers That Describe Any Distribution
The five-number summary provides a compact non-parametric description of any dataset — no assumptions about shape required.
- Minimum and Maximum — The boundaries of your data
- Q1 and Q3 — The edges of the middle 50%
- Median — The center that splits data exactly in half
- Box plot foundation — These five numbers draw every box plot
- IQR from Q1 and Q3 — The robust measure of spread comes directly from this summary
Five numbers. One complete picture. The five-number summary is the Swiss Army knife of descriptive statistics.
What You'll Learn
- 1Compute the five-number summary and the interquartile range from ordered data
- 2Explain why different software packages report slightly different quartiles
- 3Apply the 1.5 x IQR rule to classify outliers and draw whisker endpoints
- 4Read skewness and spread directly from a box plot of the summary
What Is the Five-Number Summary?
Definition
The five-number summary consists of five descriptive statistics that divide a dataset into four equal parts: Minimum, Q1 (25th percentile), Median (50th percentile), Q3 (75th percentile), and Maximum.
| Statistic | Description |
|---|---|
| Minimum | Smallest non-outlier value |
| Q1 | 25th percentile (lower quartile) |
| Median | 50th percentile |
| Q3 | 75th percentile (upper quartile) |
| Maximum | Largest non-outlier value |
The summary answers three questions at once: where the data start and stop, where the centre sits, and how much spread the middle half shows. That last quantity, the interquartile range , is the robust counterpart to the standard deviation. Half the observations lie inside it by definition, so it needs no assumption about tail weight and barely moves when a few extreme values are added or removed. The mean and standard deviation, by contrast, respond to every single value and can be dragged across the range by a handful of points.
Robustness has a precise meaning here. The median keeps its value until you delete more than half the data; the quartiles break down at 25 percent; the minimum and maximum break down as soon as one observation is contaminated. This ordering — 50, 25, 0 percent breakdown — explains why box plots remain trustworthy on messy real data where mean-and-standard-deviation dashboards quietly mislead.
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
tips = sns.load_dataset('tips')
print("=== Five-Number Summary: Total Bill ===")
bill = tips['total_bill']
q1, med, q3 = np.percentile(bill, [25, 50, 75])
iqr = q3 - q1
lower_fence = q1 - 1.5*iqr
upper_fence = q3 + 1.5*iqr
not_outlier = bill[(bill >= lower_fence) & (bill <= upper_fence)]
print(f"Min (non-outlier): ${not_outlier.min():.2f}")
print(f"Q1: ${q1:.2f}")
print(f"Median: ${med:.2f}")
print(f"Q3: ${q3:.2f}")
print(f"Max (non-outlier): ${not_outlier.max():.2f}")
print(f"IQR: ${iqr:.2f}")
print(f"Lower fence: ${lower_fence:.2f}")
print(f"Upper fence: ${upper_fence:.2f}")
outliers = bill[(bill < lower_fence) | (bill > upper_fence)]
print(f"Outliers: {sorted(outliers.values)}")
Which Quartile Definition Does Your Tool Use?
There is no single agreed rule for placing the cut between the lower and upper halves, and at least nine variants appear across packages. The differences are invisible for large samples and can be surprising for small ones.
Take the ordered values 3, 5, 7, 9, 11, 13, 15, 17, 19, 40. The median is unambiguous at , but the quartiles are not:
| Definition | Rule for Q1 | Q1 here | Q3 here | Where you meet it |
|---|---|---|---|---|
| Tukey hinges | Median of the lower half, including the median when n is odd | 7.0 | 17.0 | Textbooks, hand-drawn box plots |
| Linear on the (n−1) grid | Position 0.25 × (n − 1) | 7.5 | 16.5 | numpy, pandas, R type 7, Excel QUARTILE.INC |
| Position q(n + 1) | Position 0.25 × (n + 1) | 6.5 | 17.5 | R type 6, Excel QUARTILE.EXC |
All three are defensible; they differ only in where they imagine the observations to lie between order statistics. The practical rule is to use one definition consistently and to say which one you used whenever a quartile is quoted in a report, because a reader reproducing your numbers with a different default will not match them exactly.
# Same data, three quartile definitions
x = np.array([3, 5, 7, 9, 11, 13, 15, 17, 19, 40])
def tukey_hinges(v):
med = np.median(v)
lo, hi = v[v <= med], v[v >= med]
return np.median(lo), np.median(hi)
print("numpy linear Q1/Q3:", np.percentile(x, [25, 75]))
print("type 6 (q(n+1)) :", np.percentile(x, [25, 75], method='median_unbiased'))
print("Tukey hinges :", tukey_hinges(x))
The 1.5 × IQR Outlier Rule
Fences sit 1.5 interquartile ranges below Q1 and above Q3. Anything outside is flagged as an outlier, and the whiskers of a box plot extend only to the most extreme value that still lies inside. The factor 1.5 is a convention rather than a law: Tukey chose it because for a normal distribution it lands close to the points where the tails become visually notable, and a second fence at 3 × IQR marks extreme outliers separately.
For the worked dataset the IQR is 10 under Tukey's hinges, so the fences are and . The value 40 falls outside the upper fence and is plotted as a lone point; the whiskers stop at 3 and 19 rather than at 3 and 40. That distinction matters when you read someone else's plot: the box, whiskers, and dots carry separate information, and the printed "maximum" of the five-number summary is 40 while the upper whisker endpoint is 19.
A Complete Worked Example
Ordered data: 3, 5, 7, 9, 11, 13, 15, 17, 19, 40. Split at the median 12.
- Lower half: 3, 5, 7, 9, 11 → Q1 = 7
- Upper half: 13, 15, 17, 19, 40 → Q3 = 17
- Median = 12, IQR = 10, range = 37
- Fences: −8 and 32 → 40 is an outlier
- Whisker endpoints: 3 and 19
The box spans 7 to 17 with the median line at 12, sitting 5 units from Q1 and 5 from Q3 — an immediately symmetric middle half despite the extreme value at the top. Read that way, the summary says the distribution is symmetric except for one high point, which is a far more accurate description than "mean 13.9, standard deviation 11.1" would convey. The gap between the median and the mean is itself a skewness signal: whenever the mean sits well above the median, a long right tail is pulling it.
pandas describe() — Extended Summary
print(tips.describe().round(2))
# Shows: count, mean, std, min, Q1, Q2, Q3, max for all numeric columns
describe() returns the five-number summary with two additions — the mean and the standard deviation — and the comparison between those two pairs is diagnostic in itself. When the mean and median sit close together and the min and max are roughly equidistant from the centre, the distribution is symmetric; when the mean runs well above the median and the maximum is far further out than the minimum, the data are right-skewed. DataFrame.quantile([0.1, 0.25, 0.5, 0.75, 0.9]) returns any set of percentiles when the deciles matter as well.
Comparing Groups with Five-Number Summaries
fig, ax = plt.subplots(figsize=(10, 5))
groups = tips.groupby('day')['total_bill']
for i, (day, group) in enumerate(groups):
q1, med, q3 = np.percentile(group, [25, 50, 75])
iqr = q3 - q1
whisker_lo = group[group >= q1-1.5*iqr].min()
whisker_hi = group[group <= q3+1.5*iqr].max()
outliers = group[(group < whisker_lo) | (group > whisker_hi)]
# Draw box
ax.barh(i, q3-q1, left=q1, height=0.4, color='steelblue', alpha=0.7)
ax.plot([med, med], [i-0.2, i+0.2], 'red', lw=2)
ax.plot([whisker_lo, q1], [i, i], 'black', lw=1)
ax.plot([q3, whisker_hi], [i, i], 'black', lw=1)
ax.scatter(outliers, [i]*len(outliers), color='red', zorder=5, s=20)
print(f"{day}: Min={whisker_lo:.1f} Q1={q1:.1f} Med={med:.1f} Q3={q3:.1f} Max={whisker_hi:.1f}")
ax.set_yticks(range(4))
ax.set_yticklabels(['Thursday','Friday','Saturday','Sunday'])
ax.set_xlabel('Total Bill ($)')
ax.set_title('Five-Number Summary: Total Bill by Day')
plt.tight_layout()
plt.savefig('five_num_summary.png', dpi=150)
plt.show()
Stacked box plots turn the comparison into a visual question about three things: shift (do the medians line up?), spread (are the boxes the same width?), and shape (is the median centred in its box and are the whiskers balanced?). A group whose median sits at the 75th percentile of another group shows overlap in the boxes yet a clear distributional difference, which a t-test on means would report less directly.
Five-Number Summary in Machine Learning
| ML Application | 5-Number Usage | Why |
|---|---|---|
| EDA | Quick data understanding | First step before modeling |
| Box plots | Visual model diagnostics | Compare model errors |
| Data validation | Check for data issues | Pipeline monitoring |
| Feature profiling | Summary statistics per feature | Automated EDA reports |
import numpy as np
import pandas as pd
from sklearn.datasets import load_iris
# Five-number summary for EDA
iris = load_iris()
df = pd.DataFrame(iris.data, columns=iris.feature_names)
print("Five-Number Summary for Iris Dataset:")
for col in df.columns:
q1, med, q3 = df[col].quantile([0.25, 0.5, 0.75])
print(f" {col:25s}: Min={df[col].min():.1f}, Q1={q1:.1f}, "
f"Med={med:.1f}, Q3={q3:.1f}, Max={df[col].max():.1f}")
Monitoring pipelines lean on this heavily because the five numbers are cheap to store, easy to compare across days, and robust to the occasional bad row. Comparing yesterday's Q1 and Q3 against the training distribution catches a shift in the middle of the data that a change in the mean would miss, while a drifting maximum usually signals a broken range check rather than a genuine change in the population. For model diagnostics, the five-number summary of residual magnitudes per group reveals which segments the model handles poorly without requiring any distributional fit.
Common Mistakes
Treating the maximum as the upper whisker
Fix: The whisker ends at the largest value inside the 1.5 x IQR fence. Beyond it, individual points are drawn separately, so the summary maximum and the whisker endpoint are different quantities.
Quartiles that will not reproduce in another tool
Fix: Packages default to different definitions. State the method — Tukey hinges, linear interpolation, or q(n+1) — whenever quartiles appear in a report.
Deleting every point outside the fences
Fix: Fences flag unusual values, not errors. In skewed data the flagged points are often the most important observations, so investigate before excluding and document any removal.
Best Practices
- Order the data before computing anything; quartiles are defined on the sorted sequence
- Report the median and interquartile range rather than mean and standard deviation for skewed variables
- Show the individual points alongside box plots for small groups so the reader can see what the summary summarises
Key Takeaways
- Min, Q1, Median, Q3, Max define a box plot — the five-number summary IS a box plot
- No distributional assumptions are required, and the median and quartiles resist contamination far better than mean and standard deviation
- Outliers are defined by the 1.5 x IQR rule, not by the min and max, and the whiskers stop at the last value inside the fences
- Software differs on quartile placement: for 3, 5, 7, 9, 11, 13, 15, 17, 19, 40 the definitions give Q1 of 6.5, 7.0, or 7.5
Frequently Asked Questions
Is the maximum always part of the five-number summary?
Yes, and it is also the value most likely to be an outlier. Box plots therefore show two different upper bounds: the summary maximum, which is the largest observation, and the upper whisker, which is the largest observation inside the 1.5 × IQR fence. Reading a printed summary against a plotted box requires keeping the two apart.
Why is the IQR preferred to the standard deviation for skewed data?
The interquartile range depends only on the middle half of the observations, so extreme values cannot inflate it. The standard deviation squares every deviation, letting one large value dominate, which makes it a poor summary of spread whenever the distribution is asymmetric or heavy tailed.
How does the five-number summary relate to skewness?
Compare the distances: when the median sits closer to Q1 than to Q3 and the upper whisker runs longer than the lower one, the distribution is right-skewed. Pearson's second coefficient of skewness turns exactly this into a number through , which is why the mean and standard deviation from describe() belong beside the five-number summary rather than in place of it.
Interview Questions
Q1: What are the five numbers and what does each one tell you?
Minimum, first quartile, median, third quartile, and maximum. They give the range, the boundaries of the middle 50 percent, and the centre, and together they define every box plot.
Q2: How do you identify outliers with the five-number summary?
Compute IQR = Q3 − Q1, set fences at Q1 − 1.5 × IQR and Q3 + 1.5 × IQR, and flag any value outside. The whiskers then extend to the most extreme value that remains inside.
Q3: Why do two tools disagree on Q1 for the same data?
There is no unique convention for splitting a sample into halves. Tukey hinges take the median of the lower half, numpy and R type 7 interpolate at 0.25(n−1), and type 6 interpolates at 0.25(n+1); all converge as n grows.
Q4: When would you report the five-number summary instead of mean and standard deviation?
Whenever the data are skewed, contain outliers, or are ordinal. The median and IQR stay stable under contamination, while the mean and standard deviation move with every extreme value.