2.7.4 · D3Statistics & Probability — Intermediate

Worked examples — Box-and-whisker plots — quartiles, IQR

2,444 words11 min readBack to topic

The scenario matrix

Before working anything, let us list every case class this topic can throw at you. Think of it like a checklist of "shapes of data" — each row is a situation where the procedure branches (does something different).

# Case class What is tricky about it Example that covers it
A odd Median is a real data point; drop it from both halves Ex 1
B even Median is an average of two points; halves split cleanly Ex 2
C Half-size odd ( leaves 3-per-half etc.) themselves are single middle values Ex 1, Ex 3
D Half-size even ( are averages) need their own averaging step Ex 3
E Repeated values Repeats still count as separate positions Ex 4
F Outlier on the high side Upper fence catches it; whisker stops short Ex 2, Ex 5
G Outlier on the low side Lower fence catches it (people forget this side!) Ex 5
H All values identical (degenerate) ; fences collapse onto the value Ex 6
I Smallest possible set () Boundary case for the halving rule Ex 3
J Real-world word problem (units, meaning) Must interpret, not just compute Ex 7
K Exam twist — find a missing value given Work the rule backwards Ex 8

Every cell above is hit by at least one worked example below. Let us go.


Ex 1 — Case A + C: odd , single-value quartiles

Step 1 — Sort ascending. . Why this step? Quartiles are defined by position in a sorted queue; positions are meaningless until we sort.

Step 2 — Median . Position → the 4th value . Why this step? With 7 items there is exactly one item in the dead centre — three below, three above.

Step 3 — Split, dropping the median. Lower half ; upper half . Why this step? is odd, so the median belongs to neither side — including it would make the halves unequal.

Step 4 — = medians of the halves. Each half has 3 values → middle one. , . Why this step? is "the median of the lower half" — that is the median-of-half rule from the parent note.

Step 5 — IQR. .

Verify: Below sits only (1 of 7 ≈ 14%, near 25% for tiny ✓). Below the median sit = 3 of 7 ≈ 43% ≈ 50% ✓. All quartiles are actual data points, as expected for odd . ✓


Ex 2 — Case B + F: even , high-side outlier

Step 1 — Already sorted. . Confirm ascending ✓. Why this step? Never assume — a hidden unsorted value breaks everything.

Step 2 — Median . Even : average positions 4 and 5 → . Why this step? No single middle item exists for even ; the fair centre sits between the two middle values.

Step 3 — Split into two halves of 4. Lower ; upper . Why this step? Even divides cleanly into two equal groups; the median is not a data point so nothing is dropped.

Step 4 — (each half is even → average). Lower middle pair . Upper middle pair . Why this step? Each half has 4 items — even — so its median is itself an average of two middles.

Step 5 — IQR and fences. Why this step? The fences are the "1.5 boxes out" yardstick — anything beyond them is unusual.

Step 6 — Flag outliers. outlier. The right whisker stops at the largest value , which is . Why this step? Whiskers reach the last non-outlier, not the fence.

Figure — Box-and-whisker plots — quartiles, IQR

Verify: All fences are consistent (lower < < median < < upper ✓). is above the upper fence; nothing is below , so no low outlier. Right whisker end . ✓


Ex 3 — Case D + I: smallest set (), averaged quartiles

Step 1 — Sort. . Why this step? Same reason as always — positions need order.

Step 2 — Median . Even : average of the 2nd and 3rd values . Why this step? No single middle; the centre lies between and .

Step 3 — Split. Lower ; upper . Why this step? even → clean 2/2 split, no value dropped.

Step 4 — Quartiles as averages. , . Why this step? Each half has 2 values (even) → median is their average. This is Case D: the quartiles themselves need averaging.

Step 5 — IQR. .

Verify: ✓, spacing symmetric because the data is symmetric ✓. This is the boundary case: is the fewest points for which "median of each half" still produces two-element halves. ✓


Ex 4 — Case E: repeated values

Step 1 — Already sorted, (odd). Confirm ✓. Why this step? Order first — repeats stay in place.

Step 2 — Median . Position → 5th value . Why this step? Nine items → the 5th is the exact centre. We count positions, not distinct values — the three 7s occupy positions 2, 3, 4 separately.

Step 3 — Split, drop median. Lower ; upper . Why this step? Odd → median (position 5) belongs to neither half.

Step 4 — Quartiles. Lower half has 4 values (even) → . Upper half → . Why this step? Repeats do not collapse: the lower half's middle pair is the 2nd and 3rd 7s, and .

Step 5 — IQR. .

Verify: (repeated value can legitimately equal a quartile), , IQR ; ordering holds ✓.


Ex 5 — Case F + G: outliers on BOTH sides

Step 1 — Sort. — already ascending, . Why this step? Confirm order; the negative must sit first.

Step 2 — Median . Average of 4th & 5th . Why this step? Even → averaged centre.

Step 3 — Split into 4/4. Lower ; upper .

Step 4 — Quartiles. , . Why this step? Each half even → average the middle pair. Notice and sit at the edges of the halves, so they barely affect — that is robustness in action.

Step 5 — Fences.

Step 6 — Flag BOTH sides. low outlier; high outlier. Left whisker stops at (smallest value ); right whisker stops at . Why this step? The fence rule is symmetric — you must test both directions every time.

Verify: Two outliers, one each side; IQR unchanged by the wild edge values (compare: plain range !) — a vivid demo that IQR is robust while range is not. (Range and Spread, Outliers and Robust Statistics.) ✓


Ex 6 — Case H: degenerate, all values identical

Step 1 — Sorted (trivially), . All equal. Why this step? Even identical data must be treated by the same rule — no shortcuts.

Step 2 — Median. Average of 3rd & 4th .

Step 3 — Halves. Lower , upper , .

Step 4 — IQR and fences. Why this step? With zero spread the box has zero width — it collapses to a single vertical line at 20, whiskers vanish, and no point can be an outlier (nothing is beyond ).

Verify: IQR , both fences , no outliers — the degenerate case behaves sensibly. A box plot here is just a line. ✓


Ex 7 — Case J: real-world word problem (with units)

Step 1 — Sort. Already ascending, . Why this step? Confirm; the sits last.

Step 2 — Median . Average of 6th & 7th minutes. Why this step? Even → centre between positions 6 and 7.

Step 3 — Split into 6/6. Lower ; upper .

Step 4 — Quartiles. Lower middle pair (3rd,4th) min. Upper middle pair (3rd,4th of upper ) → min. Why this step? Each half has 6 (even) → average middle pair.

Step 5 — Interpret IQR + fences. Since a wait can't be negative, the lower fence is effectively "no lower outliers possible." → the 25-minute wait is an outlier.

Step 6 — Answer in words. "The middle half of customers waited within a 4-minute band (from 3.5 to 7.5 min), with a typical wait of 5 min. One customer's 25-minute wait was an outlier — flag it for investigation." Why this step? A word problem demands interpretation with units, not just a number.

Verify: , , IQR min, upper fence min, → outlier ✓. Units carried throughout (minutes). ✓


Ex 8 — Case K: exam twist, work the rule BACKWARDS

Step 1 — Identify and structure. (even) → lower half is the first 4 values . Why this step? is the median of the lower half; only those 4 values matter.

Step 2 — Write in terms of . Lower half has 4 values (even) → . Why this step? We reverse the usual computation: express the quantity we know as a formula in the unknown.

Step 3 — Solve. . Why this step? Simple algebra once the relationship is set up.

Step 4 — Check the constraint. satisfies ✓ and keeps the list sorted () ✓. Why this step? An exam wants you to confirm the answer is admissible, not just algebraically valid.

Verify: With the lower half is , whose median is ✓. The dataset stays sorted. ✓


Recall Which cell did each example hit?

Ex 1 → A,C · Ex 2 → B,F · Ex 3 → D,I · Ex 4 → E · Ex 5 → F,G · Ex 6 → H · Ex 7 → J · Ex 8 → K. Every matrix cell is covered.


Connections