Sub topic 3
Range: The Simplest Measure of Spread
This chapter assumes you can order numbers from least to greatest, find a median, and subtract with negative numbers. It also assumes you can read values off a labeled number line. You do not need quartiles yet. The range is the first measure of spread you will meet, and the later measures (the interquartile range, the boxplot) are built to fix the problems you will see here.
What spread means
The median describes where the center of a data set sits. It says nothing about how tightly the values cluster around that center. Two classes can both have a median quiz score of 80. In one class every student scored between 78 and 82. In the other, scores run from 40 to 100. A single center value cannot tell these apart. A measure of spread can.
The range is the simplest such measure. It is the distance from the smallest value to the largest value.
Computing the range
You only need two values: the largest and the smallest. Sorting the data first is the safest way to find them. After sorting, the minimum is the first entry and the maximum is the last.
Take the data set 14, 3, 21, 8, 12, 5, 18, 7, 13. Sorted, it is 3, 5, 7, 8, 12, 13, 14, 18, 21. The minimum is 3 and the maximum is 21, so the range is 21 − 3 = 18.
Here is the same calculation in code, using the data set from the Topic Spine:
def data_range(data):
return max(data) - min(data)
data = [14, 3, 21, 8, 12, 5, 18, 7, 13]
print(sorted(data)) # [3, 5, 7, 8, 12, 13, 14, 18, 21]
print(data_range(data)) # 18The range is never negative, because the maximum is at least as large as the minimum. It is zero only when every value is identical. A range of 0 means there is no spread at all.
Ranges with negative numbers
Subtracting a negative number adds its size. For the data −6, −2, 0, 4, 9, the range is 9 − (−6) = 15. A common slip is to compute 9 − 6 = 3. Write the subtraction with parentheses so the sign is not lost.
Ranges from a frequency table
Sometimes the data arrive as a table of values and how often each appears.
| Score | Frequency |
|---|---|
| 1 | 4 |
| 2 | 0 |
| 3 | 6 |
| 5 | 2 |
The range uses only values that actually occur. Score 2 has frequency 0, so it is not in the data. The minimum is 1, the maximum is 5, and the range is 4. The frequencies do not change the range. A value that appears 500 times affects it no more than a value that appears once, provided neither is the minimum or the maximum.
Units and interpretation
The range has the same units as the data. If the data are heights in centimeters, the range is in centimeters. If the data are test scores out of 100, the range is in points. A GRE question may ask you to state or compare ranges, so check that both quantities use the same unit before you compare them.
In a sentence: "The scores span 18 points from lowest to highest." This is the full meaning of the range. It reports the width of the interval that contains all the data and nothing else.
Why the range is a weak measure
The range depends on only two values, the two extremes. Every other value in the data set can change without affecting it. This causes two problems.
The range ignores how the middle is arranged
These three sets all have the same range, 18, and the same median, 12:
def data_range(data):
return max(data) - min(data)
def median(values):
s = sorted(values)
n = len(s)
mid = n // 2
if n % 2 == 1:
return s[mid]
return (s[mid - 1] + s[mid]) / 2
sets = {
"A": [3, 5, 7, 8, 12, 13, 14, 18, 21],
"B": [3, 12, 12, 12, 12, 12, 12, 12, 21],
"C": [3, 3, 3, 3, 12, 21, 21, 21, 21],
}
for name, values in sets.items():
print(name, data_range(values), median(values))
# A 18 12
# B 18 12
# C 18 12Set B is bunched tightly around 12, with just two extreme values. Set C has no values near the center at all, and every value sits at one end or the other. Set A is somewhere in between. By eye these sets have very different shapes, yet the range and the median cannot distinguish them. This is the reason the quartiles and the interquartile range exist. They look at where the middle half of the data lies.
The range is sensitive to extreme values
Because the range depends on the extremes, one unusual value can change it a lot. Consider the data 10, 11, 11, 12, 12, 13. The range is 3. Now add one value, 40. The data become 10, 11, 11, 12, 12, 13, 40, and the range jumps to 30. The bulk of the data did not move, but the range grew tenfold.
Adding a value to a data set can never decrease the range. The new value is either between the old minimum and maximum, so the range is unchanged, or it is outside them, so the range grows. Removing a value can never increase the range, and it lowers the range only if you remove the unique minimum or the unique maximum.
How the range changes under simple operations
GRE questions sometimes ask what happens to a statistic when every value is changed in the same way. The range responds as follows.
| Operation on every value | Effect on the range | Column | Column |
|---|---|---|---|
| Add a constant k | No change | ||
| Subtract a constant k | No change | ||
| Multiply by k | New range = \ | k\ | × old range |
| Divide by k (k not 0) | New range = old range ÷ \ | k\ |
Adding a constant slides the whole data set along the number line. Every value moves by the same amount, so the distance between the minimum and maximum stays the same. Multiplying stretches or shrinks the distances. A negative multiplier also flips the order, so the old maximum becomes the new minimum. The range is still a positive width, which is why the absolute value appears.
def data_range(data):
return max(data) - min(data)
data = [3, 5, 7, 8, 12, 13, 14, 18, 21]
print(data_range(data)) # 18
print(data_range([x + 10 for x in data])) # 18, shifting changes nothing
print(data_range([x * 3 for x in data])) # 54, scaled by 3
print(data_range([x * -2 for x in data])) # 36, scaled by |-2|A frequent error is to multiply the range by −2 and report −36. A range cannot be negative.
Combining two data sets
Suppose set X has values from 3 to 21 and set Y has values from 10 to 30. What is the range of the combined data, with all values from both sets?
The combined minimum is the smaller of the two minimums, which is 3. The combined maximum is the larger of the two maximums, which is 30. The combined range is 30 − 3 = 27.
You cannot get this by adding or averaging the two ranges. X has range 18 and Y has range 20, and neither 38 nor 19 is correct. You also cannot find the combined range from the two ranges alone. You need the actual minimums and maximums. Without them, the best you can say is a bound. The combined range is at least as large as the larger of the two individual ranges, and it can be much larger when the sets sit far apart on the number line.
The range on a boxplot
A boxplot displays the minimum and maximum at the ends of its whiskers, so you can read the range from the picture as the distance from one whisker end to the other. You will see how to read the plot in a later chapter.
One caution applies now. Some boxplots mark outliers as separate points beyond the whiskers. In that case the whisker ends are not the true minimum and maximum, and the range of the whole data set is measured out to the outlying points. If a question says "range of the data", include any plotted outliers. If a question refers to the whiskers, use the whisker ends. Read the wording and the figure's legend before you subtract.
Strategies for GRE questions
- Locate the extremes and ignore the rest. For a range question you need two numbers. Do not spend time sorting a long list. Scan for the largest and the smallest values.
- Check for negative values. Write the subtraction in full, such as 9 − (−6).
- Use only values that exist. In a frequency table, skip rows with frequency 0.
- Compare ranges in the same units. Convert first if the two sets use different units.
- Think about extremes when a value is added or removed. The range moves only when the new or removed value is an extreme.
- Do not infer the center or the typical spread from the range. It tells you nothing about the median and little about the middle of the data.
Where this leads
The range uses the whole distance from the lowest to the highest value, so it is only as stable as those two values. The next measures improve on this. Quartiles mark the points that split the ordered data into four parts. The interquartile range is the distance covered by the middle half of the data, so a single extreme value cannot distort it. Throughout, the range remains useful as a quick description of the total span and as one of the five numbers in the five-number summary.
Exercise
The data set is 12, −4, 7, 0, 19, 7, −4. (a) What is the range? (b) What is the range after every value is multiplied by −3 and then 5 is added?
Show answer
(a) The minimum is −4 and the maximum is 19, so the range is 19 − (−4) = 23. (b) Adding 5 does not change the range. Multiplying by −3 scales it by |−3| = 3, so the new range is 3 × 23 = 69. Check: the new values run from 19 × (−3) + 5 = −52 up to −4 × (−3) + 5 = 17, and 17 − (−52) = 69.
Exercise
Set P has minimum 15 and maximum 40. Set Q has range 30 and minimum 22. Both sets are combined. What is the smallest possible range of the combined data, and what is the largest possible range?
Show answer
Set P has range 25. Set Q runs from 22 to 52, because its maximum is 22 + 30. The combined minimum is the smaller of 15 and 22, which is 15. The combined maximum is the larger of 40 and 52, which is 52. Here the sets are fully specified by their minimums and ranges, so the combined range is 52 − 15 = 37. It is the only possible value, so the smallest and the largest are both 37.
Exercise
A data set of 20 test scores has a range of 12. A new score is added that is lower than every existing score, and the range becomes 30. By how much was the new score below the old minimum?
Show answer
The range grew from 12 to 30, an increase of 18. The maximum did not change, so the minimum fell by 18. The new score was 18 points below the old minimum.