Quartiles and the IQR
Imagine lining up all 32 runners in a race by their finish times, then splitting the line into
four equal groups: the fastest quarter, the next quarter, the next, and the slowest quarter.
The three points where you cut are the quartiles. They give you a robust,
at-a-glance picture of where the middle of your data lives — and how tightly it clusters
— without a single wild value being able to throw the whole story off.
The median already
splits sorted data into two halves. Quartiles go one step further and split it into four equal
quarters using three cut points:
- Q_1 — the lower quartile: a quarter of the data lie below it.
- Q_2 — the median: half lie below it.
- Q_3 — the upper quartile: three quarters lie below it.
Here is the trick that makes them easy to find: each quartile is itself a median.
Q_2 is the median of the whole set; Q_1 is
the median of the lower half; Q_3 the median of the upper half. If you
can find a median, you can find all three quartiles.
Worked example: finding all three quartiles
Take eight sorted values — say the number of books eight friends read last month:
2,\; 4,\; 5,\; 7,\; 8,\; 11,\; 12,\; 16.
There are 8 values, an even count, so the median is the average of the 4th and
5th: Q_2 = \tfrac{7 + 8}{2} = 7.5. That splits the data into a lower
half \{2, 4, 5, 7\} and an upper half
\{8, 11, 12, 16\}.
- Lower half median: Q_1 = \tfrac{4 + 5}{2} = 4.5.
- Upper half median: Q_3 = \tfrac{11 + 12}{2} = 11.5.
So the middle half of the data runs from 4.5 up to
11.5.
The interquartile range
The distance between the outer quartiles is the interquartile range:
\text{IQR} = Q_3 - Q_1.
It is the width of the middle 50% of the data. For the books example above,
\text{IQR} = 11.5 - 4.5 = 7 books. Unlike the
range, which
is decided entirely by the two most extreme points, the IQR throws those extremes away. That
makes it robust: a single wild outlier can blow up the range but barely
nudges the IQR.
Worked example: why "robust" matters
Nine houses on a street have these prices (in hundreds of thousands):
3,\; 3,\; 4,\; 4,\; 5,\; 5,\; 6,\; 6,\; 7.
Here the range is 7 - 3 = 4, and the quartiles are
Q_1 = 4, Q_3 = 6, so
\text{IQR} = 2. Now a mansion sells and the last value jumps from
7 to 90:
3,\; 3,\; 4,\; 4,\; 5,\; 5,\; 6,\; 6,\; 90.
- The range explodes from 4 to
90 - 3 = 87 — more than twentyfold.
- The standard deviation similarly balloons, because it squares that huge gap.
- The IQR stays at 2 (the quartiles
Q_1 = 4 and Q_3 = 6 haven't budged) —
the outlier is out past the whisker where the IQR simply doesn't look.
One point changed the range by a factor of twenty and left the IQR untouched. That is exactly
why analysts reach for the IQR when a data set might contain a rogue value.
The 1.5 × IQR rule for outliers
Because the IQR ignores extremes, it makes a great ruler for spotting them. The classic
rule builds two "fences" one and a half IQRs beyond the box:
\text{lower fence} = Q_1 - 1.5\,\text{IQR}, \qquad \text{upper fence} = Q_3 + 1.5\,\text{IQR}.
Any value beyond a fence is flagged as a suspected outlier. Back to the book
example, where Q_1 = 4.5, Q_3 = 11.5 and
\text{IQR} = 7:
\text{upper fence} = 11.5 + 1.5 \times 7 = 11.5 + 10.5 = 22.
So a friend who read 16 books is not an outlier (it sits
below 22), but a friend who read 30 would
be flagged. The 1.5 isn't sacred — it is Tukey's convenient default
that catches genuinely stray points without crying wolf over ordinary variation.
The boxplot
A boxplot draws all five summary numbers at once. For the sorted data set
3, 5, 6, 7, 8, 9, 11, 13, 15, 21 the quartiles are
Q_1 = 6, median = 8.5 and
Q_3 = 13, so \text{IQR} = 13 - 6 = 7. The
box runs from Q_1 to Q_3
with the median marked inside; the whiskers reach out to the smallest and
largest values.
At a glance the box shows where the central half of the data sits, and the whiskers show how
far the tails stretch. A long whisker on one side already hints at
skew.
- Q_1, the median Q_2, and Q_3 cut sorted data into four equal quarters.
- The interquartile range \text{IQR} = Q_3 - Q_1 is the spread of the middle 50%.
- The IQR is robust — it ignores the extreme values, so outliers barely affect it.
- A boxplot draws the five-number summary: min, Q_1, median, Q_3, max.
Quartiles look unambiguous, but they hide a genuine catch: there are several accepted
conventions for computing them, and they can disagree. The main sticking points are how
to handle an odd number of values and whether the median itself belongs to the halves:
- The exclusive method (Tukey's) drops the median from both halves when the
count is odd, then takes each half's median.
- The inclusive method keeps the median in both halves.
- Some software instead interpolates to a fractional position between two data
points.
For the same seven numbers, a graphing calculator, a spreadsheet's QUARTILE.EXC,
and a statistics package can each report a slightly different Q_1.
None is "wrong" — they are different reasonable choices. So if two people quote different
quartiles for one data set, don't panic: check which convention each used. (The median
Q_2 is the same under all of them.)
The boxplot is the handiwork of John Tukey (1915–2000), a Bell Labs
polymath and one of the founders of exploratory data analysis — the art of letting a
data set show you its shape before you commit to any model. In the 1970s he wanted a picture you
could sketch by hand that captured a whole distribution in five numbers: min,
Q_1, median, Q_3, max. The box-and-whisker
plot was the answer, and it lets you eyeball spread (box width),
skew (a lopsided box or one long whisker), and outliers (dots
stranded past the fences) all at once.
Tukey had a knack for the useful and the memorable: he also coined the words "bit"
(for binary digit) and popularised "software." Not a bad legacy for someone
whose day job was inventing ways to look at numbers.
See it explained