2.7.4Statistics & Probability — Intermediate

Box-and-whisker plots — quartiles, IQR

1,866 words8 min readdifficulty · medium1 backlinks

WHY do we need quartiles at all?

The mean tells you a "centre", but it lies to you when data is skewed or has outliers (one billionaire ruins the average income). We want a description that is robust — insensitive to a few extreme values.

Idea: instead of averaging, just sort the data and mark positions. If you stand in a queue of incomes ordered small→large, "the person exactly in the middle" (the median) is a fair centre no matter how rich the richest is.

Extend the idea: mark the person 1/4 of the way, and 3/4 of the way. Now you have three cut points splitting the queue into four equal parts. Those cut points are the quartiles.


HOW to compute quartiles (from scratch)

Step 0 — sort the data ascending. (Everything below assumes this.)

Step 1 — median Q2Q_2:

  • nn odd → middle value, position n+12\frac{n+1}{2}.
  • nn even → average of the two middle values.

Step 2 — split into halves. The lower half = all values below the median position; upper half = all above.

  • If nn is odd, the median itself is not placed in either half.
  • If nn is even, the two halves each get exactly n/2n/2 values.

Step 3 — Q1Q_1 = median of lower half, Q3Q_3 = median of upper half.


IQR — the spread of the middle 50%


Detecting outliers — the 1.5 × IQR fences

We need a rule for "unusually far from the pack." Tukey's rule builds a fence using the IQR as a natural yardstick.

WHY 1.5? It's a convention chosen so that, for roughly normal data, only about 0.7% of points get flagged — rare enough to be interesting, not so strict that nothing shows. (Multiplier 3.0 marks "far out" extreme outliers.)


Anatomy of the plot

Figure — Box-and-whisker plots — quartiles, IQR
  • Left whisker end → smallest non-outlier
  • Box left edgeQ1Q_1
  • Line in box → median Q2Q_2
  • Box right edgeQ3Q_3
  • Right whisker end → largest non-outlier
  • Dots beyond whiskers → outliers

Worked Example 1 — odd nn

Data: 7, 2, 9, 4, 5, 12, 37,\ 2,\ 9,\ 4,\ 5,\ 12,\ 3 (n=7n=7)

Sort: 2,3,4,5,7,9,122,3,4,5,7,9,12Why? Quartiles are defined by position, meaningless unsorted.

Median Q2Q_2: position 7+12=4\frac{7+1}{2}=4 → value 55. Why? Middle of 7 items.

Lower half (below the median, exclude it): 2,3,42,3,4. → Q1=3Q_1 = 3. Upper half: 7,9,127,9,12. → Q3=9Q_3 = 9. Why exclude the median? nn odd, so it belongs to neither half.

IQR =93=6= 9-3 = 6.

Fences: 31.5(6)=63 - 1.5(6) = -6; 9+1.5(6)=189 + 1.5(6) = 18. No value outside → no outliers.


Worked Example 2 — even nn + an outlier

Data (sorted): 1, 3, 3, 4, 5, 6, 6, 7, 8, 301,\ 3,\ 3,\ 4,\ 5,\ 6,\ 6,\ 7,\ 8,\ 30 (n=10n=10)

Median: average of 5th & 6th values =5+62=5.5=\frac{5+6}{2}=5.5. Why? Even nn, no single middle.

Lower half (first 5): 1,3,3,4,51,3,3,4,5Q1=3Q_1 = 3 (its median). Upper half (last 5): 6,6,7,8,306,6,7,8,30Q3=7Q_3 = 7. Why split 5/5? Even nn divides cleanly.

IQR =73=4= 7 - 3 = 4.

Upper fence =7+1.5(4)=13= 7 + 1.5(4) = 13. The value 30>1330 > 13outlier! Why does this matter? The right whisker stops at 88 (largest value ≤ 13), and 3030 is drawn as a lone dot.


Forecast-then-Verify


Recall Feynman: explain it to a 12-year-old

Line up all your friends shortest to tallest. The kid exactly in the middle is the median. Now find the middle of the shorter half and the middle of the taller half — those two split everyone into four equal groups. The box plot is just a box drawn from the first split to the third split, with a line at the middle. The whiskers are arms reaching out to the shortest and tallest kids who aren't weirdly extreme. If someone is super far out (like a giant), we draw them as a lonely dot — that's an outlier.


Recall checklist


Connections

  • Median and Measures of Central TendencyQ2Q_2 is the median.
  • Range and Spread — IQR is the robust cousin of range.
  • Outliers and Robust Statistics — the 1.5×IQR rule lives here.
  • Percentiles and Quantiles — quartiles are the 25/50/75 percentiles.
  • Skewness — box asymmetry reveals skew.
  • Normal Distribution — why 1.5 flags ≈0.7%.

What is the median Q2Q_2 of a data set?
The middle value of the sorted data (or the average of the two middle values if nn is even).
How do you find Q1Q_1?
Sort the data, find the median, then take the median of the lower half (excluding the median itself if nn is odd).
Define the IQR.
IQR=Q3Q1\text{IQR} = Q_3 - Q_1 — the range of the central 50% of the data.
Why is IQR preferred over the range for spread?
It ignores the extreme outer 25% on each side, so it's robust to outliers, whereas range uses only max and min.
State the outlier fences.
Lower =Q11.5IQR= Q_1 - 1.5\,\text{IQR}; Upper =Q3+1.5IQR= Q_3 + 1.5\,\text{IQR}; points outside are outliers.
Where does a whisker end?
At the most extreme data value still inside the fences — not at the fence itself.
For 2,3,4,5,7,9,122,3,4,5,7,9,12 find Q1,Q2,Q3Q_1,Q_2,Q_3.
Q2=5Q_2=5, Q1=3Q_1=3, Q3=9Q_3=9, IQR =6=6.
Why the multiplier 1.5 in the outlier rule?
Convention: for roughly normal data it flags only ~0.7% of points — rare enough to be notable but not over-sensitive.

Concept Map

fails on skew or outliers

sort and mark positions

median of lower half

median of upper half

four equal-count parts

four equal-count parts

Q3 minus Q1

Q3 minus Q1

robust vs plain range

1.5 x IQR yardstick

beyond fences

drawn as box

width of box

Mean centre

Need robust description

Median Q2

Q1 lower quartile

Q3 upper quartile

Quartiles

IQR spread of middle 50%

Robust spread measure

Tukey fences

Outliers

Box-and-whisker plot

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, box plot ka basic idea simple hai: apne data ko sort karo, aur usko 4 equal parts mein todo. Beech wala cut point median (Q2Q_2) hai — yeh centre batata hai. Fir lower half ka median Q1Q_1 hota hai aur upper half ka median Q3Q_3. Yahi teen cut points quartiles kehlate hain. Iska sabse bada faida yeh hai ki median aur quartiles outliers se disturb nahi hote — agar ek banda crore ki salary leke aa jaaye, average toh hil jaata hai, par median chill rehta hai.

IQR ka matlab hai Q3Q1Q_3 - Q_1, yaani beech ke 50% data ka spread. Yeh normal range (max − min) se better hai kyunki range sirf do extreme points pe depend karta hai, jabki IQR outer 25% ko ignore kar deta hai. Isliye IQR ko "robust" spread bolte hain.

Outlier pakadne ke liye 1.5 × IQR fence rule use karo: lower fence =Q11.5IQR= Q_1 - 1.5\,\text{IQR}, upper fence =Q3+1.5IQR= Q_3 + 1.5\,\text{IQR}. Jo point in fences ke bahar hai, woh outlier hai aur usko lonely dot ki tarah draw karte hain. Whisker fence tak nahi, balki fence ke andar wale sabse door data point tak jaata hai — yeh point yaad rakhna, exam mein log yahin galti karte hain.

Yaad rakhne ka trick: "Sort, Split, Snip" — pehle sort, fir median pe split, fir har half ka apna median nikaalo. Agar nn odd hai toh median ko halves mein mat daalo. Bas itna dhyan rakho aur box plot ekdum easy ho jaayega.

Go deeper — visual, from zero

Test yourself — Statistics & Probability — Intermediate

Connections