Sub topic 6
The Five-Number Summary
What the Summary Contains
The five-number summary describes a data set with five values, listed from least to greatest:
- The minimum
- The first quartile, Q1
- The median, Q2
- The third quartile, Q3
- The maximum
This chapter assumes you can already order a data set, find a median, and split a data set into halves to get quartiles. It also assumes you know the range and the interquartile range (IQR). The five-number summary packages all of these into one object. From it you can read the range (maximum minus minimum) and the IQR (Q3 minus Q1) without looking at the raw data.
The summary is the direct input to a boxplot. Every boxplot question on the GRE is, underneath, a question about these five numbers.
Why Five Numbers
The mean and standard deviation describe a data set with two numbers, but they are pulled around by extreme values. The five-number summary uses positions in the ordered list instead of sums, so one very large value changes only the maximum. It shows three things at once:
- Center: the median.
- Spread: the range and the IQR.
- Shape: how far the median sits from Q1 and Q3, and how far the extremes sit from the quartiles.
The cost is that the summary discards everything between the five points. Two very different data sets can share the same summary.
Computing the Summary
The procedure is the one from the quartiles chapter:
- Sort the data.
- Take the minimum and maximum from the ends.
- Find the median of the whole list. This is Q2.
- Split the list into a lower half and an upper half. If the count is odd, leave the middle value out of both halves.
- Q1 is the median of the lower half. Q3 is the median of the upper half.
def median(values):
n = len(values)
mid = n // 2
if n % 2 == 1:
return values[mid]
return (values[mid - 1] + values[mid]) / 2
def five_number_summary(data):
s = sorted(data)
half = len(s) // 2
lower = s[:half]
upper = s[half + len(s) % 2:] # skip the middle value when n is odd
return s[0], median(lower), median(s), median(upper), s[-1]
data = [3, 5, 7, 8, 12, 13, 14, 18, 21]
mn, q1, q2, q3, mx = five_number_summary(data)
print(mn, q1, q2, q3, mx) # 3 6.0 12 16.0 21
print("range:", mx - mn) # range: 18
print("IQR:", q3 - q1) # IQR: 10.0For the nine values above, the middle value is 12, so the lower half is 3, 5, 7, 8 and the upper half is 13, 14, 18, 21. Q1 is the average of 5 and 7, which is 6. Q3 is the average of 14 and 18, which is 16.
Worked Example with an Even Count
With an even number of values, no value is left out. Take 2, 4, 4, 6, 9, 11, 15, 20.
- Minimum: 2. Maximum: 20.
- Median: the average of the 4th and 5th values, (6 + 9) / 2 = 7.5.
- Lower half: 2, 4, 4, 6. Q1 = (4 + 4) / 2 = 4.
- Upper half: 9, 11, 15, 20. Q3 = (11 + 15) / 2 = 13.
The five-number summary is 2, 4, 7.5, 13, 20. The range is 18 and the IQR is 9.
What the Spacing Tells You
Each gap between neighboring summary values covers about a quarter of the data. The four gaps are:
| Section | From | To | Share of data |
|---|---|---|---|
| Lower whisker | Minimum | Q1 | About 25% |
| Lower box | Q1 | Median | About 25% |
| Upper box | Median | Q3 | About 25% |
| Upper whisker | Q3 | Maximum | About 25% |
The data are split evenly by count, but the sections are not equal in length. A long section means the values in that quarter are spread out. A short section means they are packed together.
For the even-count example, the gaps are 2 (2 to 4), 3.5 (4 to 7.5), 5.5 (7.5 to 13), and 7 (13 to 20). The gaps grow from left to right, so the upper quarters are more spread out than the lower ones. This pattern is called right skew: the long tail points toward larger values.
Reading Features from the Summary
You can draw several conclusions without the raw data.
- Range: maximum minus minimum. It depends on only two values.
- IQR: Q3 minus Q1. It describes the middle half of the data and ignores the extremes.
- Skew hint: compare Q2 - Q1 with Q3 - Q2. If the upper gap is larger, the middle of the data leans right. Also compare the two whisker lengths.
- Symmetry check: in a symmetric data set, the median sits near the middle of the box and the two whiskers are about equal.
The range is always at least as large as the IQR. They are equal only when the minimum equals Q1 and the maximum equals Q3.
Outlier Check from the Summary
The summary is enough to apply the 1.5 times IQR rule when a problem states it. For the first example, Q1 = 6, Q3 = 16, and IQR = 10. The fences are 6 - 15 = -9 and 16 + 15 = 31. The minimum 3 and maximum 21 lie inside the fences, so the data set has no outliers by this rule.
def outlier_fences(q1, q3):
iqr = q3 - q1
return q1 - 1.5 * iqr, q3 + 1.5 * iqr
low, high = outlier_fences(6, 16)
print(low, high) # -9.0 31.0Common Errors
- Skipping the sort. Quartiles of an unsorted list are meaningless. Sort first.
- Including the middle value in both halves. For an odd count, leave the median out when forming the halves. Some textbooks include it, which gives slightly different quartiles. On the GRE, a problem that depends on the difference will normally give you the quartiles or use a data set where the methods agree.
- Treating the five numbers as percents. Q1 is a value in the data, not "25". The first quartile is the 25th percentile, which is a position, and its value is whatever number sits there.
- Assuming equal lengths. Each quarter holds about the same number of values, but the lengths on the number line usually differ.
- Using the range as the spread of the middle. The range includes the extremes. For the middle half, use the IQR.
- Confusing the mean with the median. The summary contains the median, not the mean. In right-skewed data, the mean is usually larger than the median, but the summary alone cannot give you the mean.
A Tempting Reading That Fails
Suppose a problem says that the minimum is 10, Q1 is 20, the median is 30, Q3 is 40, and the maximum is 90. A student might say that "half of the values are between 20 and 40, so the average of those values is 30." The first part is true, since the IQR covers the middle half. The second part does not follow. The values between 20 and 40 might cluster near 20 and 40 or near 30, and their mean could be anything in that interval. The summary fixes the quartile positions, not the average.
A safer inference is that at least one quarter of the values are 20 or less and at least one quarter are 40 or more. For this chapter's purposes, every claim about proportions should be framed as "about a quarter" or "about half" unless the data set is given.
Summary of the Method
The five-number summary reduces an ordered data set to its extremes, its median, and its two quartiles. Range and IQR come from subtracting. The gaps between the numbers show where data are packed or spread. The next chapters use these values to interpret percentiles and to read and draw boxplots.
Exercise
A data set has the values 4, 6, 9, 10, 12, 15, 21, 30. Give the five-number summary, then compute the range and the IQR. Finally, state whether the upper half of the data is more spread out than the lower half.
Show answer
The list is already sorted and has 8 values. The minimum is 4 and the maximum is 30. The median is (10 + 12) / 2 = 11. The lower half is 4, 6, 9, 10, so Q1 = (6 + 9) / 2 = 7.5. The upper half is 12, 15, 21, 30, so Q3 = (15 + 21) / 2 = 18. The summary is 4, 7.5, 11, 18, 30. The range is 30 - 4 = 26 and the IQR is 18 - 7.5 = 10.5. The lower gaps are 3.5 and 3.5. The upper gaps are 7 and 12. The upper half is more spread out, so the data are right-skewed.
Exercise
A five-number summary is 12, 25, 40, 46, 70. A student claims that the lower half of the data is more tightly packed than the upper half. Is the student correct? Which quarter spans the greatest distance, and are there any outliers under the 1.5 times IQR rule?
Show answer
Not correct. The gaps are 13 (12 to 25), 15 (25 to 40), 6 (40 to 46), and 24 (46 to 70). The lower half spans 12 to 40, a distance of 28. The upper half spans 40 to 70, a distance of 30. These are close, but the upper half is slightly wider, and its spread is concentrated in the top quarter. The student's claim happens to hold only by a small margin and is a weak conclusion. The quarter with the greatest distance is the top one, from Q3 to the maximum (24). The IQR is 46 - 25 = 21, so the fences are 25 - 31.5 = -6.5 and 46 + 31.5 = 77.5. The minimum 12 and maximum 70 are inside the fences, so there are no outliers.
Exercise
Two data sets both have the five-number summary 5, 10, 15, 20, 25. Must they have the same mean? Must they have the same number of values?
Show answer
No to both. The summary fixes only the five positions. Different values between the points can give different means, and the data sets can have different counts.