The Interquartile Range and Boxplots
A single elephant seal bull can outweigh every female in his harem combined. Suppose a biologist averages the body masses of a beach colony. That one bull can drag the mean far above what any "typical" seal weighs. This is the everyday problem of skewed and outlier-prone data in biology. Clutch sizes, parasite loads, gene expression counts, hospital wait times — all tend to behave this way. They pile up near zero and stretch out in a long right tail. The Mean, Median, and Mode and Variance and Standard Deviation describe such data. But the mean and standard deviation are notoriously sensitive to extreme values. So they can mislead exactly when biological data misbehave. The interquartile range (IQR) offers a fix. It is a measure of spread built entirely from ranks. It is immune to how extreme the extremes are. It asks a simple question — how spread out is the middle half of the data. It ignores everything happening in the tails. Paired with the median, the IQR gives a two-number summary: center and spread. This summary survives contamination by a mistyped value, a sick outlier animal, or a genuinely rare biological event. This article builds the IQR from percentiles and quartiles. It shows exactly how boxplots turn five numbers into a picture. It walks through the classic logic connecting robustness to breakdown points. It also works two nontrivial biological examples — one on parasite counts, one on enzyme activity — to fixed numerical answers. It closes by flagging where the IQR is about to matter most: as the ruler used to formally flag Outliers in Biological Data.
- Percentiles rank-order data; the pth percentile has p% of observations at or below it.
- Quartiles are the 25th, 50th, and 75th percentiles (Q1, Q2 = median, Q3).
- IQR = Q3 − Q1: the range of the middle 50% of the data.
- IQR is robust — unaffected by any change to the top or bottom 25% of values, unlike the standard deviation.
- Boxplots visualize five numbers: minimum, Q1, median, Q3, maximum (with outliers plotted separately using the 1.5×IQR rule).
- Right-skewed biological data (parasite loads, gene counts, reaction times) are best summarized by median and IQR, not mean and SD.
The IQR measures the spread of the middle half of a dataset and, because it ignores the extreme 25% on each side, stays stable even when the data contain severe outliers or skew.
The core idea
A percentile locates a value within a ranked dataset: the pth percentile is the value below which p percent of the observations fall. To find it, sort the data from smallest to largest, then walk to the position that is p% of the way along that ordered list. Different textbooks use slightly different interpolation rules for non-integer positions, but the concept is always the same: percentiles are about rank, not magnitude. This is the crucial difference from the mean, which is a magnitude-based average — swap one data point for a much larger one, and the mean shifts, but a data point's percentile rank barely moves unless it crosses another value's rank.
Quartiles are the three percentiles that cut a dataset into four equal-sized groups:
| Quartile | Percentile | Meaning |
|---|---|---|
| Q1 | 25th | one quarter of data ≤ this value |
| Q2 | 50th | the median |
| Q3 | 75th | three quarters of data ≤ this value |
The interquartile range is defined as
It is the width of the interval containing the central 50% of observations — trim away the bottom quarter and the top quarter of the sorted data, and IQR is simply the range of what remains. Because Q1 and Q3 are themselves percentiles, IQR inherits their key property: robustness. You can take the single largest value in a dataset and multiply it by a thousand, and — as long as it doesn't change which observations occupy the 25th and 75th rank positions — the IQR does not change at all. The standard deviation, in stark contrast, would explode. This robustness comes at a cost: the IQR discards information. It says nothing about how spread apart the extreme values are, and two datasets with wildly different tails can share an identical IQR. That is precisely the trade the IQR makes deliberately, and it is why the choice between "mean & SD" versus "median & IQR" is really a choice about which kind of description you trust for your data.
Mechanism — computing quartiles and building a boxplot
Step 1 — Sort. Arrange the n observations from smallest to largest.
Step 2 — Find the median (Q2). This splits the ordered data into a lower half and an upper half. (Convention varies on whether the median observation itself, when n is odd, is included in both halves; the method below — sometimes called the Tukey or "hinge" method — excludes it, which is the most common convention taught alongside boxplots.)
Step 3 — Find Q1 and Q3. Q1 is the median of the lower half; Q3 is the median of the upper half. Statistical software (R's default, Excel, etc.) may use slightly different interpolation formulas for percentiles that fall between two data points, so Q1 and Q3 can differ by a small amount across software — this is normal and rarely matters biologically.
Step 4 — Compute the IQR. IQR = Q3 − Q1.
Step 5 — Build the five-number summary.
Step 6 — Detect candidate outliers (Tukey's fences). Define inner fences at
Any observation beyond these fences is flagged as a potential outlier and plotted individually in a boxplot rather than being absorbed into the whisker. (Some biological software also uses 3×IQR "far outlier" fences to distinguish mild from extreme outliers — a refinement worth knowing but not required for a basic boxplot.)
Step 7 — Draw the box and whiskers. The box spans Q1 to Q3, with a line at the median. Whiskers extend from the box edges out to the most extreme data point that still lies inside the fences. Points beyond the fences are drawn as individual dots.
(Note the figure's arithmetic is illustrative of the splitting procedure; the worked example below uses this exact dataset with the correct median computed explicitly.)
Reading a boxplot is a rank-based act: the box's height (or width, if horizontal) is IQR itself, the line inside is the median, and the whiskers show the reach of the "typical" non-outlying data. Skew is visible directly — if the upper whisker is much longer than the lower one, or the median line sits off-center in the box, the underlying distribution is skewed, exactly the situation where mean and SD would misrepresent the data.
The evidence
Unlike phenomena such as Natural Selection or DNA replication, the IQR is not a biological law confirmed by a single decisive experiment — it is a statistical convention, and its "evidence" is the historical demonstration that rank-based summaries perform better than moment-based summaries (mean, SD) on real, messy data. Two strands of evidence matter here.
1. John Tukey's development of robust, resistant statistics (1970s). The statistician John W. Tukey, working at Princeton and Bell Labs, formalized exploratory data analysis (EDA) in his 1977 book Exploratory Data Analysis. He introduced the boxplot ("box-and-whisker plot"), the term "hinges" for quartile-like values, and the 1.5×IQR fence rule for flagging outliers. Tukey's key argument, backed by simulation and by re-analysis of many real datasets (economic, physical, and biological), was that summary statistics should be resistant — insensitive to a small fraction of "wild" data points. He demonstrated this concretely with breakdown point analysis: the mean has a breakdown point of 0% (a single arbitrarily extreme value can move it without bound), whereas the median and IQR have breakdown points near 25–50% (up to a quarter of the data must be corrupted before the IQR is arbitrarily distorted, since Q1 and Q3 themselves are protected by the 25% of data trimmed on each side).
2. Repeated demonstration on skewed biological and medical datasets. Across ecology, parasitology, and clinical biostatistics, empirical comparisons consistently show the same pattern: for right-skewed data (parasite egg counts, viral titers, hospital length-of-stay, income, reaction times), the mean is pulled toward the tail and can lie above the 70th or 80th percentile of the data, while the median stays near the visual "center of mass" of the bulk of observations. Rosner's Fundamentals of Biostatistics and Zar's Biostatistical Analysis both use paired real and simulated examples — e.g., hospital charges, or bacterial colony counts — to show that reporting "mean ± SD" for such data can describe a value that few or no actual patients/organisms resemble, whereas "median (IQR)" better reflects a typical case. This is not a single crucial experiment but a large, converging body of applied statistical practice, which is why median/IQR reporting is now mandated by many biomedical journals (e.g., ICMJE-affiliated journals) whenever a Shapiro-Wilk or visual assessment shows non-normality. The logical proof of robustness itself, though, can be shown exactly, the way one proves a theorem: take any dataset, replace its single largest value with an arbitrarily large number, and observe algebraically that Q1, the median, and Q3 (hence the IQR) are unchanged, because none of those three statistics depend on the magnitude of the top 25% of points — only on which values sit in which rank positions. This is a deductive guarantee, not an empirical one, and it is the mathematical bedrock beneath Tukey's practical recommendation.
Worked examples
Example 1 — Parasite egg counts in a fish population (asymmetric, right-skewed). A parasitologist counts trematode eggs per gram (EPG) of fecal matter in 12 wild-caught minnows:
The value 42 is a heavily infected fish — plausible biologically (a few individuals often carry disproportionate parasite burdens due to immune variation), but it will distort a mean-based summary. Step 1 — sort: already sorted, n = 12. Step 2 — median: n is even, so median = average of the 6th and 7th values = (8 + 9)/2 = 8.5. Step 3 — lower half (first 6 values): 2, 3, 5, 6, 7, 8. Q1 = median of these six = (5 + 6)/2 = 5.5. Step 4 — upper half (last 6 values): 9, 11, 13, 14, 16, 42. Q3 = median of these six = (13 + 14)/2 = 13.5. Step 5 — IQR:
Step 6 — outlier fences:
The value 42 exceeds 25.5, so it is flagged as a statistical outlier and would be drawn as an individual point beyond the whisker, not absorbed into it — foreshadowing how boxplots are used to formally screen Outliers in Biological Data. Compare summaries:
| Statistic | Value |
|---|---|
| Mean | 11.3 EPG |
| Median | 8.5 EPG |
| SD | ≈ 10.9 EPG |
| IQR | 8 EPG |
The mean (11.3) is pulled well above the median (8.5) by that single heavily infected fish, and removing the 42 changes the mean substantially (recompute without it: mean of the remaining 11 values = 84/11 ≈ 7.6, a drop of nearly 4 units) while the median and IQR barely move. This is robustness demonstrated numerically, not just asserted.
Example 2 — Comparing enzyme activity between two treatment groups. A biochemist measures the activity of an enzyme (units: nmol product/min/mg protein) after treating cell cultures with either a vehicle control or a novel inhibitor. n = 9 per group. Control group (sorted): 40, 44, 47, 50, 52, 55, 58, 60, 63 Inhibitor group (sorted): 5, 8, 9, 11, 12, 14, 15, 60, 62 Control group: Median (5th of 9) = 52. Lower half (40,44,47,50): Q1 = (44+47)/2 = 45.5. Upper half (55,58,60,63): Q3 = (58+60)/2 = 59. IQR = 59 − 45.5 = 13.5. Inhibitor group: Median (5th of 9) = 12. Lower half (5,8,9,11): Q1 = (8+9)/2 = 8.5. Upper half (14,15,60,62): Q3 = (15+60)/2 = 37.5. IQR = 37.5 − 8.5 = 29. Interpretation: the inhibitor dramatically lowers typical enzyme activity (median drops from 52 to 12 — a roughly 77% reduction), consistent with successful inhibition in most cells. But the inhibitor group's IQR (29) is more than double the control's (13.5), showing the treatment response is far more variable across cultures — some cells (the two values at 60 and 62) appear essentially resistant to inhibition. A mean-and-SD summary would average the resistant and responsive cells together and might suggest a smaller, more uniform effect than what's biologically happening: most cells are strongly inhibited, but a resistant subpopulation is not, a pattern the median/IQR framework reveals cleanly and that a boxplot would show visually as a short box for control and a tall, asymmetric box for the inhibitor group with two high outlying points.
Common misconceptions & traps
| Misconception | Reality |
|---|---|
| "IQR is the range of all the data." | IQR is the range of only the middle 50%; the full range (max − min) is a different, much less robust statistic. |
| "Q2 and the median are different things." | Q2 is the median — the 50th percentile. |
| "Points outside the whiskers are always errors." | Tukey's fences flag statistical outliers based on rank distance; whether they are measurement errors or real biological extremes requires judgment, not just the rule. |
| "A wider box always means more observations." | Box width shows spread (IQR value), not sample size — boxplots do not directly encode n unless annotated. |
| "Quartiles split data into four equal-width intervals." | Quartiles split data into four groups of equal count, not equal numeric width — intervals can differ greatly in width if data are skewed. |
| "IQR and SD measure the same thing, just scaled differently." | They agree closely only for symmetric, roughly normal data; for skewed or heavy-tailed data they can diverge sharply, as in Example 1. |
The scientist behind it
Origins · 1 minJohn Wilder Tukey and how this was discovered
Tukey trained originally as a chemist and mathematician (PhD, Princeton, 1939) before turning to statistics, where he became one of the most prolific and inventive statisticians of the century. Working across academia (Princeton) and industry (Bell Labs), he moved fluidly between deep theory and hands-on, "look at your data first" pragmatism. He coined the terms "bit" (binary digit) and "software," co-invented the Fast Fourier Transform algorithm with James Cooley, and — most relevant here — created the boxplot and the broader philosophy of exploratory data analysis: the idea that before fitting models and testing hypotheses, a statistician should visualize and summarize data using methods resistant to contamination by outliers or misspecified distributions.
Where this matters today
Clinical biostatistics and journal reporting. Major biomedical journals now recommend reporting "median (IQR)" rather than "mean ± SD" whenever a variable — hospital length of stay, biomarker concentration, tumor size — is skewed or has extreme values, because the median/IQR pair better represents what a typical patient experiences and is not distorted by a handful of critically ill outliers.
Flow cytometry and single-cell genomics. Gene expression counts and fluorescence intensities from single-cell RNA sequencing are famously right-skewed, with many near-zero counts and a long tail of highly expressed cells; IQR-based normalization and boxplot visualization are standard quality-control tools before formal modeling begins.
Ecology and parasitology. Parasite loads, clutch sizes, and abundance counts across individuals or sites are classically overdispersed and skewed; ecologists routinely report median and IQR (or use boxplots to compare sites/treatments) rather than assuming near-normal distributions that means and SDs implicitly suggest.
Agricultural and pharmaceutical quality control. Boxplots comparing crop yields, drug potency batches, or pesticide residue levels across treatment groups let inspectors spot both a shift in typical value (median) and a change in consistency (IQR) at a glance, flagging problem batches via out-of-fence points without a full formal outlier test.
Conservation biology. When comparing body condition indices or contaminant levels across small, precious populations (endangered species with n in the single digits to dozens), robust statistics matter enormously — a single unusually large or small measurement, common with tiny sample sizes, can otherwise swamp mean-based comparisons between populations or years.
Ask the tutor: How do I decide, for a real dataset, whether to report mean±SD or median (IQR) — and what formal test or visual check should guide that choice?
Why use the median and IQR instead of the mean and SD at all?
Because the mean and SD are calculated from every value's exact magnitude, a single extreme observation — a mistyped value, a rare biological extreme, a sick or unusually large individual — can shift them substantially, sometimes without limit. The median and IQR are calculated from ranks: which observations fall in the middle, not how far the extremes stretch. For skewed or outlier-prone biological data (parasite loads, hospital stays, gene expression), this makes median/IQR summaries far more representative of what's typical, while mean/SD remains preferable for roughly symmetric, well-behaved data where it uses more information efficiently.
Do Q1 and Q3 always use the same interpolation method?
No. When the 25th or 75th percentile falls between two data points, different conventions (Tukey's hinges, linear interpolation, nearest-rank methods) give slightly different answers. R's default `quantile()` function, Excel, and Minitab can each report marginally different Q1/Q3 values for the same dataset. This rarely changes the biological conclusion, but it means you should not expect two software packages to report bit-for-bit identical quartiles — always check which method your software or the appropriate reporting guideline uses.
What exactly counts as an "outlier" in a boxplot?
A point is flagged when it falls beyond the inner fences: below Q1 − 1.5×IQR or above Q3 + 1.5×IQR. This is a statistical convention, not a biological judgment — some analyses further distinguish "mild" outliers (beyond 1.5×IQR) from "extreme" outliers (beyond 3×IQR). Flagging is only the first step; the analyst must then decide, using biological or methodological knowledge, whether the flagged point is an error, a rare-but-real event, or evidence of a distinct subpopulation.
Can the IQR be zero?
Yes — if at least half of the dataset's central values are identical (specifically, if Q1 equals Q3), the IQR is zero. This happens with highly discrete or heavily tied data, such as many small counts equal to the same integer, and signals that the middle half of the data has essentially no spread, even if the tails vary. It's a useful check: an IQR of zero with a nonzero range tells you the data are concentrated with a few tail values pulling away from a dense central cluster.
How does IQR relate to percentiles in general, beyond just quartiles?
Quartiles are simply the 25th, 50th, and 75th percentiles — a special case of the general percentile idea. Some fields use other percentile-based spread measures, such as the 90th-minus-10th-percentile range, which captures more of the tails than the IQR but is still more robust than the full range. The underlying logic — measure spread using rank positions rather than raw magnitudes — is the same whether you use quartiles, deciles, or any other percentile pair.
Should I ever report both IQR and standard deviation?
Sometimes, yes. Reporting both can be informative: if IQR and SD agree closely (roughly IQR ≈ 1.35 × SD for a normal distribution), the data are probably close to symmetric and unimodal; a large divergence signals skew or heavy tails worth investigating further, often with a histogram or boxplot alongside the numbers. Many applied papers report the boxplot's five-number summary as the primary description and mention SD only as a secondary check.
Is the IQR ever misleading?
Yes — because it only examines the middle 50%, two datasets with drastically different tail behavior (one with no outliers, one with a handful of extreme values) can have identical IQRs. If the biological question is specifically about extreme events — die-off thresholds, maximum toxin tolerance, worst-case clinical outcomes — the IQR by design throws away exactly the information you need, and range, maximum, or tail-percentile statistics should be reported alongside it.