MathemagiciansLibraryExplorationsDeep Dives
← Mathematics · Upper Secondary
MathematicsUpper Secondary

Comparing distributions using box plots

U4 — Statistics Advancing › U4.1 — Cumulative Frequency and Box PlotsLecture 4 of 4~2710 words

The faster route that makes you miss the train

Rahel takes a bus to the station every morning. Her train leaves 30 minutes after she reaches the bus stop. Two bus routes go to the station. She timed Route A on 20 mornings and Route B on 60 mornings. Here are the two box plots, drawn on one scale.

Route A (n = 20)Route B (n = 60)1015202530354045Journey time (minutes)
Route A: 21, 23, 24, 26, 30 minutes. Route B: 12, 18, 23, 31, 44 minutes. The dashed line marks 30 minutes, the time before her train leaves.

Which route should she take? The usual first answer compares the middles. Route B's median is 23 minutes and Route A's is 24 minutes. So Route B is faster on a typical morning.

But look at Route B's box. Its upper quartile is 31 minutes. So about a quarter of Route B's journeys took 31 minutes or more. On those mornings, Rahel misses her train. Route A's longest journey in 20 mornings was 30 minutes. She caught the train every time, once only just.

So the faster route is the wrong choice. One number for the middle could not show this. You need the middle and the spread, and you need to read them against the question that matters to Rahel.

The last lecture said that box plots would be placed side by side, and that groups of different sizes could be compared fairly. Here it is. Notice that Rahel timed the two routes on different numbers of mornings, 20 and 60. That does not matter, because each box plot speaks in quarters. This lecture shows how to compare two box plots fully, and how to write the comparison so that it means something.

Two comparisons, every time

Every comparison of two box plots starts with two things.

Why the median, and not the mean? A box plot does not show the mean. You cannot read it from the picture, because the individual values are gone. The median is also resistant: the last lecture showed that one extreme value cannot drag it.

Why the IQR, and not the range? The range uses only the two most extreme values in each group. One strange value can make it huge. The IQR describes the middle half of the group, so one strange value cannot change it. Worked Example 2 shows when the range still adds something.

A comparison is not finished when the numbers are written down. Each one needs a sentence about the context. "The median of B is lower" is a fact about the picture. "On a typical morning, Route B takes about 1 minute less" is a conclusion about the buses. The conclusion is what the question asks for.

Write it for Rahel's routes.

The second comparison decides the question. Rahel needs a bus she can rely on, not a bus that is fast on an average morning.

Reading one group against the other's quarters

Two comparisons are the minimum. The real power of side-by-side box plots comes from a third move: take a number from one group and see where it falls in the other group's quarters.

Look at the two classes below. They took the same test, out of 100. Class A has 30 students and Class B has 32.

Class A (n = 30)Class B (n = 32)30405060708090100Test score (out of 100)
Class A: 32, 48, 61, 74, 90. Class B: 40, 55, 68, 79, 95. The dashed line marks Class A's median, 61.

Class A's median is 61. Follow the dashed line down into Class B. It lands inside the left half of Class B's box, between B's lower quartile (55) and B's median (68).

Now use what each part of Class B's box plot means. A quarter of Class B scored below 55. Half of Class B scored below 68. A score of 61 sits between these two. So between a quarter and a half of Class B scored below 61. Turn that round: between a half and three quarters of Class B scored above 61.

In Class A, exactly half the class scored above 61, by the meaning of the median. In Class B, more than half did. That is a precise, honest statement. It does not pretend to know the exact number, and it does not need the mean.

That is it. That is the whole idea. Every number on a box plot marks a known fraction of its group: 0, a quarter, a half, three quarters, or all of it. So any number from one group can be placed among the other group's quarters. And because both groups are described in fractions, their sizes do not have to match.

Comparing two box plots

1. Centre: compare the medians, and say what the difference means in context.

2. Spread: compare the IQRs, and say which group is more consistent.

3. Quarters: place a value from one group among the other group's quarters, and state the fraction.

4. When it helps: shape (skew), outliers, the range, the sizes of the groups.

A statement about two box plots must be true, must be false, or cannot be decided from the pictures at all. Sorting statements in this way is the best practice for reading box plots honestly.

Sort — what do the two box plots tell you?

Use the box plots of Class A (n = 30: 32, 48, 61, 74, 90) and Class B (n = 32: 40, 55, 68, 79, 95). Put each statement in a box. Read the reason after each card.

Nine statements about Class A (32, 48, 61, 74, 90; n = 30) and Class B (40, 55, 68, 79, 95; n = 32), sorted.

  • Must be true. The middle student in Class B scored 7 marks more than the middle student in Class A. At least half of Class B scored more than 61. About a quarter of Class A scored 74 or more. The highest score of all was in Class B.
  • Must be false. Every student in Class B scored more than every student in Class A. More than a quarter of Class B scored below 48.
  • Cannot tell. The mean of Class B is higher than the mean of Class A. Some student in Class A scored exactly 50. More students in Class B than in Class A scored above 70.

The last card is the hardest. Both classes have between a quarter and a half above 70, but those are ranges, and the ranges overlap. When the quarters cannot settle a question, the honest answer is "cannot tell".

Stop and think

Rahel timed Route A on 20 mornings and Route B on 60 mornings. A friend says the comparison is unfair, because Route B had three times as many chances to show a long journey. Is the friend right?

Show the answer

Partly. For the box and the median, the friend is wrong. Quartiles describe fractions of the group, so "a quarter of journeys took 31 minutes or more" means the same thing for 20 mornings or 60 mornings.

For the whiskers, the friend has a point. The smallest and largest values are single mornings. A group that is measured more often has more chances to catch a rare extreme. So compare the boxes with confidence, and compare the whisker ends with care. Here the decision does not depend on the whiskers: Route B's box alone reaches past 30 minutes.

How far apart is far enough?

When two boxes sit far apart, the difference between the groups is clear. When they overlap a lot, it is not. The explorer below lets you move one group and watch what the quarters say.

Explore — slide one box plot past the other

Group A is fixed. Move Group B by choosing its median. B keeps the same shape. Watch where A's median, 50, falls among B's quarters, and whether B's median leaves A's box.

Presets:

Group A's test marks (invented) are fixed: 30, 42, 50, 61, 80. Group B has the same shape at three positions. The table shows what the quarters say each time.

Group BWhere A's median (50) falls in BShare of B above 50B's median compared with A's box
36, 44, 50, 57, 68at B's medianabout a halfinside (42 to 61)
44, 52, 58, 65, 76in B's lower whiskerat least three quarters, but not allinside (42 to 61)
52, 60, 66, 73, 84below B's smallest valueall of itbeyond A's box

Did you notice when the comparison became convincing? At 50, the two groups have the same median, and half of each group is above 50. At 58, B's median is 8 marks higher, but it is still inside A's box. At 66, B's median is beyond A's box, and every student in Group B scored more than A's middle student.

Statisticians who teach this skill use a rough guide. Suppose each group has about 20 to 40 members. If one group's median lies beyond the other group's box, it is reasonable to say that the first group really does tend to have bigger values. Between those two points, the difference may be real, or it may be chance. With much larger groups, a smaller gap is enough, because large groups vary less from one sample to the next. This guide is a first step towards hypothesis testing, which makes the idea exact at Pre-University.

Worked examples

Worked Example 1 — Two classes, compared fully

Use the box plots of Class A (n = 30: 32, 48, 61, 74, 90) and Class B (n = 32: 40, 55, 68, 79, 95). Compare the two classes.

Centre. Class B's median (68) is 7 marks higher than Class A's (61). So the typical student in Class B scored about 7 marks more.

Spread. IQR of A = 74 − 48 = 26. IQR of B = 79 − 55 = 24. These are very close. So the two classes are about equally consistent.

Quarters. A's median, 61, falls in the left half of B's box. So between a half and three quarters of Class B scored above 61, against exactly half of Class A.

Overlap. The boxes overlap from 55 to 74, and B's median (68) is inside A's box (48 to 74). So the classes are not very different. Many students in Class A beat many students in Class B. With groups of about 30, this overlap means we should be careful about calling Class B "better" in general.

Check for outliers. Class A's fences are 48 − 39 = 9 and 74 + 39 = 113. Class B's are 55 − 36 = 19 and 79 + 36 = 115. No score is outside them, so the whiskers are genuine. ✓

Worked Example 2 — Two machines making bolts

Two machines make bolts with a target diameter of 10.0 mm. A bolt is rejected if its diameter is below 9.5 mm or above 10.5 mm. Machine X: 9.2, 9.8, 10.0, 10.2, 10.8 mm. Machine Y: 9.6, 9.9, 10.1, 10.3, 10.6 mm.

Machine XMachine Y9.09.510.010.511.0Diameter (mm)
The dashed lines mark the limits, 9.5 mm and 10.5 mm. A bolt outside them is rejected.

Centre. Machine X's median is exactly on target, 10.0 mm. Machine Y's median is 10.1 mm, a little high.

Spread. Both IQRs are 0.4 mm. So the middle half of each machine's bolts is equally consistent.

Outliers first. For Machine X, 1.5 × 0.4 = 0.6. The fences are 9.8 − 0.6 = 9.2 and 10.2 + 0.6 = 10.8. X's smallest and largest bolts sit exactly on the fences. A value exactly on a fence is not an outlier. So these extremes are genuine bolts and must be taken seriously. Machine Y's fences are 9.3 and 10.9, so it has no outliers either.

Range. Here the question is about rejected bolts, so the extremes matter, and the range adds real information. Range of X = 10.8 − 9.2 = 1.6 mm. Range of Y = 10.6 − 9.6 = 1.0 mm. Machine X's extremes are much further from the target.

Quarters and rejects. For X, 9.5 lies in the lower whisker, so fewer than a quarter of its bolts are too thin, but some are. 10.5 lies in the upper whisker, so some, fewer than a quarter, are too thick. For Y, the lower whisker stops at 9.6, so no bolt is too thin. Some bolts, fewer than a quarter, are too thick.

Conclusion. The typical bolts are equally consistent. Machine X rejects bolts at both ends. Machine Y rejects only thick bolts, and its median is 0.1 mm high. If Y is adjusted down by 0.1 mm and its spread stays the same, its whole box plot moves to 9.5 to 10.5. Then it would make no rejects at all. So Y is the better machine to keep.

Worked Example 3 — Groups of very different sizes

A new maize seed was tested on 12 plots. Its yields are compared with 240 farms that used the old seed. New seed: 4.1, 5.0, 5.6, 6.3, 7.0 tonnes per hectare. Old seed: 2.2, 4.0, 4.8, 5.5, 8.9 tonnes per hectare.

Outliers first. Old seed: IQR = 5.5 − 4.0 = 1.5, and 1.5 × 1.5 = 2.25. The fences are 1.75 and 7.75. So 8.9 is an outlier: one farm with an unusual yield. Suppose the next highest old-seed farm gave 7.4. Then the whisker stops at 7.4 and 8.9 is marked with a cross. New seed: IQR = 1.3, fences 3.05 and 8.25, no outliers.

New seed (n = 12 plots)Old seed (n = 240 farms)23456789Yield (tonnes per hectare)
The new seed's box sits to the right of the old seed's. The cross at 8.9 is the old seed's outlier.

Centre. The new seed's median (5.6) is 0.8 tonnes per hectare higher than the old seed's (4.8).

Spread. The IQRs are 1.3 and 1.5, close to each other. Both seeds are about equally consistent.

Quarters. The old seed's median, 4.8, lies in the new seed's lower whisker. So at least three quarters of the new-seed plots beat the typical old-seed farm. The new seed's median, 5.6, is above the old seed's upper quartile (5.5). So fewer than a quarter of the old-seed farms reached the typical new-seed plot.

Sizes. 12 and 240 are very different, and the comparison is still fair, because both box plots describe quarters. The small group does need care. With only 12 plots, a different set of 12 could give a noticeably different box. So the conclusion is "the new seed looks better, and the result deserves a larger trial", not "the new seed is proved better". Notice also the old seed's range, 6.7, is inflated by the outlier. The range would be the wrong measure of spread here.

Trap 1 — "Higher median" read as "everyone did better"

A higher median means the middle of the group is higher. It says nothing about every member. In Worked Example 1, Class A's best student (90) beat most of Class B. To say how much the groups overlap, use the quarters.

Trap 2 — Calling the median "the average"

Write "the median" or "the typical value", not "on average". "Average" usually means the mean, and a box plot cannot show the mean. A median and a mean can even disagree about which group is higher.

Trap 3 — Forgetting which way is better

A higher median is not always good news. For times, costs and errors, lower is better. For consistency, a smaller IQR is better. Decide what "better" means in the context before you write the conclusion.

Try it yourself

Work each one on paper first. Open a hint only when you are stuck.

  1. The 100 m times, in seconds, of two athletics clubs are summarised below. Lions (n = 18): 12.1, 12.8, 13.4, 14.5, 16.0. Kites (n = 24): 11.6, 12.5, 13.0, 13.3, 14.1. Compare the two clubs in two sentences, in context.

    Hint 1

    One sentence for the medians, one for the IQRs. For a race, which is better: a lower time or a higher one?

    Hint 2

    IQR of Lions = 14.5 − 12.8. IQR of Kites = 13.3 − 12.5.

    Full answer

    Centre: the Kites' median (13.0 s) is lower than the Lions' (13.4 s). So the typical Kites runner is about 0.4 seconds faster.

    Spread: the Kites' IQR is 0.8 s and the Lions' is 1.7 s. So the Kites' times are more consistent: the middle half of the club is within 0.8 seconds.

    Check for outliers: Lions' fences are 10.25 and 17.05; Kites' are 11.3 and 14.5. Every time is inside, so the whiskers are genuine. ✓

  2. Using the same two clubs, decide whether each statement must be true, must be false, or cannot be told. (a) At least three quarters of the Kites ran faster than 13.4 s. (b) Between a quarter and a half of the Kites ran faster than 12.8 s. (c) The Lions' fastest runner is faster than every Kite.

    Hint 1

    Place 13.4 and 12.8 among the Kites' five numbers: 11.6, 12.5, 13.0, 13.3, 14.1.

    Hint 2

    13.4 is between the Kites' upper quartile (13.3) and largest value (14.1). Which part of the box plot is that?

    Full answer

    (a) Must be true. 13.4 lies in the Kites' upper whisker, above Q₃ = 13.3. About three quarters of the Kites ran 13.3 s or faster, and every one of them was faster than 13.4 s. So at least three quarters ran faster than 13.4 s.

    (b) Must be true. 12.8 lies between the Kites' Q₁ (12.5) and median (13.0). So between a quarter and a half of the Kites ran faster than 12.8 s. In the Lions, only a quarter did.

    (c) Must be false. The Lions' fastest time is 12.1 s, but the fastest Kite ran 11.6 s.

    Check: each answer used only the five numbers and the meaning of the quarters. ✓

  3. A school recorded the minutes of homework done in one evening. Year 9 (n = 40): Q₁ = 30, median = 45, Q₃ = 70. Year 11 (n = 200): Q₁ = 60, median = 80, Q₃ = 110. (a) About how many students in each year did more than 70 minutes? (b) A teacher says, "Far more Year 11 students did over 70 minutes. So Year 11 works much harder." What is wrong with this argument, and what is the fair comparison?

    Hint 1

    In Year 9, 70 is the upper quartile. In Year 11, 70 lies between Q₁ and the median.

    Hint 2

    Turn fractions into counts: a quarter of 40, and between a half and three quarters of 200.

    Full answer

    (a) Year 9: about a quarter of 40, so about 10 students. Year 11: 70 is in the left half of the box, so between a half and three quarters did more than 70 minutes. That is between 100 and 150 students.

    (b) The counts are unfair to compare, because Year 11 has five times as many students. Even with identical habits, Year 11 would have about five times as many students above any time. The fair comparison uses fractions: about a quarter of Year 9 against between a half and three quarters of Year 11. That fair comparison still shows Year 11 doing more homework. But the reason is the higher median (80 against 45 minutes), not the bigger count.

    Check: 10 is a quarter of 40, and 100 and 150 are a half and three quarters of 200. ✓

  4. Two lists of 11 values: P = 10, 20, 20, 21, 22, 30, 38, 39, 40, 40, 50 and R = 10, 15, 20, 25, 28, 30, 32, 35, 40, 45, 50. (a) Show that P and R have exactly the same box plot. (b) Describe a real difference between the two lists that the box plots hide. (c) Suggest a picture that would show it.

    Hint 1

    With n = 11, Q₁ is the 3rd value, the median the 6th and Q₃ the 9th. Remember to test for outliers too.

    Hint 2

    In list P, how many values lie between 23 and 37?

    Full answer

    (a) In both lists, the smallest value is 10, Q₁ (3rd value) = 20, the median (6th) = 30, Q₃ (9th) = 40 and the largest value is 50. IQR = 20, so the fences are −10 and 70, and neither list has an outlier. The box plots are identical.

    (b) List R is spread fairly evenly from 10 to 50. List P falls into two clumps, one around 20 to 22 and one around 38 to 40. Apart from the median, 30, no value in P lies between 23 and 37. The box plot shows the quarters, but not what happens inside each quarter, so it cannot show a gap.

    (c) A dot plot of each list, on the same scale, shows the two clumps in P at once. (A histogram, the next topic, would also show them.)

    Check: both lists add up to 330, so even their means are equal (30). Only a picture of every value separates them. ✓

The bigger idea

From the start, box plots were drawn side by side to compare groups at a glance. In 1978, Robert McGill, John Tukey and Wayne Larsen suggested two improvements. One was to draw each box with a width that grows with the size of its group, so the reader sees the sizes. The other was a "notch" around each median. Its width shrinks as the group gets bigger, and if two notches do not overlap, the medians are judged to differ by more than chance would explain.

The idea behind the notch is the one you met in the explorer. A difference in medians means more when the groups are large and their spreads are small. In 2011, Chris Wild, Maxine Pfannkuch and their colleagues in New Zealand turned this into simple guides for school students. One of them is the rule you met above: a median beyond the other box, for groups of 20 to 40. Hypothesis testing, at Pre-University, makes the same idea exact. A comparison of two box plots is the first step into one of the central questions of statistics: is this difference real, or could it be chance?

Key concepts in this lesson