Sub topic 5
The range: largest minus smallest
This chapter assumes you can subtract negative numbers, solve a one-step linear equation, and find the largest and smallest values in a list. It builds on the chapter on reading and sorting a data set. It also uses the 3x + 10 transformation that appears in the later chapter on adding, scaling, and changing values.
What the range measures
The range is the largest value in a data set minus the smallest value. It is the simplest measure of spread, which means how far apart the values are. Mean, median, and mode describe the center. The range describes how wide the data is.
For the data set 2, 4, 4, 4, 5, 5, 7, 9, the largest value is 9 and the smallest is 2. The range is 9 − 2 = 7.
Three facts follow directly from the definition:
- The range is never negative, because the largest value is at least as big as the smallest.
- The range is 0 exactly when every value is the same, for example 6, 6, 6.
- The range is measured in the same units as the data. If the data is in dollars, the range is in dollars.
Computing the range
You do not need to sort the list. Scan once for the maximum and once for the minimum, then subtract. Sorting is only useful if the list is short and you want to see both ends at once. In a sorted list the range is the last value minus the first.
The GRE often includes negative numbers, and this is where careless errors happen. Subtracting a negative number adds.
For the data set −4, 3, −1, 0, the maximum is 3 and the minimum is −4. The range is 3 − (−4) = 7. Writing 3 − 4 = −1 is a common slip. It also gives a negative range, which is impossible and should tell you something went wrong.
import statistics
def data_range(values):
if not values:
raise ValueError("range needs at least one value")
return max(values) - min(values)
data = [2, 4, 4, 4, 5, 5, 7, 9]
shuffled = [9, 4, 5, 2, 7, 4, 5, 4]
print(data_range(data)) # 7
print(data_range(shuffled)) # 7, order does not matter
print(data_range([-4, 3, -1, 0])) # 7
print(data_range([6, 6, 6])) # 0
print(statistics.mean(data)) # 5The same set in a different order gives the same range. Order never affects the range.
What the range ignores
The range depends on only two values: the largest and the smallest. Everything between them is invisible to it. Two data sets can have the same range and very different shapes.
Consider these two sets of six values:
- Set A: 0, 5, 5, 5, 5, 10
- Set B: 0, 0, 0, 10, 10, 10
Both have a range of 10 and a mean of 5. In set A, most values sit at the center. In set B, every value is far from the center. The standard deviation, covered in a later chapter, shows the difference.
import statistics
a = [0, 5, 5, 5, 5, 10]
b = [0, 0, 0, 10, 10, 10]
print(max(a) - min(a), max(b) - min(b)) # 10 10
print(round(statistics.pstdev(a), 2)) # 2.89
print(round(statistics.pstdev(b), 2)) # 5.0Equal ranges do not mean equal spread. If a GRE question asks which data set has the greater standard deviation, the range alone cannot settle it unless the values are clustered in an obvious way.
The range is also very sensitive to outliers, which are values far from the rest. Take the data 10, 11, 12, 12, 13. Its range is 3. Add one value of 40 and the range becomes 30, even though four of the five values did not move. The median barely changes in this situation, as the later chapter on outliers shows.
How changes to the data affect the range
The GRE tests whether you can predict the range after a change without recomputing everything. The rules below cover the common cases.
| Change to the data | Effect on the range |
|---|---|
| Add the same constant k to every value | Unchanged |
| Multiply every value by c | Multiplied by the absolute value of c |
| Add a new value between the current min and max (inclusive) | Unchanged |
| Add a new value outside the current min and max | Increases |
| Remove a value that is not the only max or only min | Unchanged |
| Remove the only maximum or only minimum | Decreases or stays the same |
Adding a constant
Adding k shifts every value by the same amount, including the largest and the smallest. Their difference stays the same. Shifting a list never changes how wide it is.
Multiplying by a constant
Multiplying by c stretches the list. The new range is |c| times the old range. The absolute value matters because a negative multiplier flips the order of the values. The old maximum becomes the new minimum. The range must still be positive.
data = [2, 4, 4, 4, 5, 5, 7, 9]
def data_range(values):
return max(values) - min(values)
transformed = [3 * x + 10 for x in data]
negated = [-2 * x for x in data]
print(data_range(data)) # 7
print(data_range(transformed)) # 21, which is 3 * 7, the +10 has no effect
print(data_range(negated)) # 14, which is 2 * 7, not -14The transformation 3x + 10 gives a range of 21. Only the factor 3 matters. The +10 drops out.
Adding or removing a value
Adding a value can only keep the range the same or make it larger. It stays the same when the new value falls between the current minimum and maximum. It grows when the new value is a new extreme. Removing a value does the opposite: the range can only stay the same or shrink.
A value equal to the current maximum or minimum counts as between them. It does not change the range.
Worked example: finding a missing value
The range lets you work backward. If you know the range and one end of the data, you can find the other end.
A data set has five numbers: 3, 8, 12, 5, and x. The range is 14. Find x.
- Without x, the known values have a maximum of 12 and a minimum of 3.
- If x is the new maximum, then x − 3 = 14, so x = 17.
- If x is the new minimum, then 12 − x = 14, so x = −2.
- If x lies between 3 and 12, the range would be 9, not 14. This case is impossible.
So x is 17 or −2. Both work. Check x = 17: the maximum is 17, the minimum is 3, and 17 − 3 = 14. Check x = −2: the maximum is 12, the minimum is −2, and 12 − (−2) = 14.
On the GRE, a question like this usually adds a condition such as "x is positive" or gives answer choices that rule one case out. If the question gives no such condition, the answer is not unique. In a quantitative comparison, that often makes the correct answer "the relationship cannot be determined."
Range of combined data sets
When you combine two data sets, the range of the combined set is the overall maximum minus the overall minimum. It is not the sum or the average of the two ranges.
Set P is 1, 4, 6 with a range of 5. Set Q is 3, 9, 10 with a range of 7. The combined set has a maximum of 10 and a minimum of 1, so its range is 9. Adding the ranges gives 12, which is wrong. The combined range is at least as large as the larger of the two ranges and at most the distance between the extreme values of both sets.
A related rule for a subset: the range of any part of a data set is at most the range of the whole set. A subset cannot be wider than the set it came from.
Counting and the range of integers
For a list of consecutive integers from a to b inclusive, the range is b − a, but the number of values is b − a + 1. For the integers 5 through 12, the range is 7 and there are 8 values. Mixing up these two quantities is a classic off-by-one trap. If a question gives the range of a list of consecutive integers and asks how many there are, add 1.
Common traps
- Subtracting in the wrong order or mishandling negative numbers. Always compute maximum minus minimum.
- Assuming the list must be sorted. It does not.
- Assuming that equal ranges mean equal standard deviations.
- Forgetting that multiplying by a negative number still gives a positive range.
- Forgetting that a missing-value problem may have two solutions.
- Treating the range of a combined set as the sum of the two ranges.
Exercise
A data set is 12, −3, 7, 0, 9, −3. What is the range, and what is the range after every value is multiplied by −2 and then increased by 5?
Show answer
The maximum is 12 and the minimum is −3, so the range is 12 − (−3) = 15. Multiplying by −2 multiplies the range by |−2| = 2, giving 30. Adding 5 does not change the range. The new range is 30. Check: the new values are −19, 11, −9, 5, −13, 11. The maximum is 11 and the minimum is −19, so the range is 30.
Exercise
The numbers 4, 10, 6, 15, and y have a range of 13. Find every possible value of y.
Show answer
Without y, the maximum is 15 and the minimum is 4. If y is the new maximum, y − 4 = 13, so y = 17. If y is the new minimum, 15 − y = 13, so y = 2. If y is between 4 and 15, the range is 11, not 13. So y = 17 or y = 2.
Exercise
Set M has a range of 8. Set N has a range of 5. Is the range of the combined set always 13?
Show answer
No. The combined range is the overall maximum minus the overall minimum. For example, M = 0, 8 and N = 2, 7 combine to a range of 8. The combined range can never be larger than the sum of the two ranges plus the gap between the sets, and it is at least 8, the larger of the two ranges.