Sub topic 11
Outliers and the 1.5 x IQR Rule
This chapter assumes you can find the median, Q1, Q3, and the interquartile range (IQR) of a data set, and that you can read a boxplot. If you need a refresher, review the earlier chapters on quartiles and the IQR first.
What an outlier is
An outlier is a value that sits unusually far from the rest of the data. "Unusually far" is a judgment, so statisticians use a rule to make it concrete. The most common rule uses the IQR as a yardstick for how spread out the middle half of the data is. A value is far from the middle half if it lies more than 1.5 IQRs beyond the quartile on its side.
On the GRE, you will usually not be asked to decide on your own what counts as an outlier. The problem will state the rule, or it will show a boxplot where outliers are already drawn as separate points. Your job is to apply the rule exactly.
The 1.5 x IQR rule
Compute the IQR, then build two cutoffs called fences:
- Lower fence = Q1 − 1.5 × IQR
- Upper fence = Q3 + 1.5 × IQR
A value is an outlier if it is below the lower fence or above the upper fence. A value that lies exactly on a fence is not beyond it, so it is not an outlier under this rule.
A first example
The earlier chapters used the data set 3, 5, 7, 8, 12, 13, 14, 18, 21. Its quartiles are Q1 = 6 and Q3 = 16, so the IQR is 10.
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.0
# A value below -9 or above 31 would be flagged as an outlier.The fences are −9 and 31. Every value in the data set lies between them, so this data set has no outliers. The largest value, 21, is only 5 above Q3, well inside the allowed 15.
Applying the rule step by step
- Order the data.
- Find Q1 and Q3 using the method from the quartiles chapter.
- Compute IQR = Q3 − Q1.
- Compute 1.5 × IQR, then the two fences.
- Compare each value to the fences. Anything strictly outside is an outlier.
A second example, with an outlier
Add the value 40 to the original set. The data now has ten values: 3, 5, 7, 8, 12, 13, 14, 18, 21, 40.
- The lower half is 3, 5, 7, 8, 12, so Q1 = 7.
- The upper half is 13, 14, 18, 21, 40, so Q3 = 18.
- The median is (12 + 13) / 2 = 12.5.
- IQR = 18 − 7 = 11, and 1.5 × 11 = 16.5.
- Lower fence = 7 − 16.5 = −9.5. Upper fence = 18 + 16.5 = 34.5.
Since 40 > 34.5, the value 40 is an outlier. The next largest value, 21, is inside the fence, so it is not.
The code below repeats this calculation and also finds where the whiskers will end.
def median(values):
n = len(values)
mid = n // 2
if n % 2 == 1:
return values[mid]
return (values[mid - 1] + values[mid]) / 2
def quartiles(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 median(lower), median(s), median(upper)
data = [3, 5, 7, 8, 12, 13, 14, 18, 21, 40]
q1, q2, q3 = quartiles(data)
iqr = q3 - q1
low, high = q1 - 1.5 * iqr, q3 + 1.5 * iqr
outliers = [v for v in data if v < low or v > high]
inside = [v for v in data if low <= v <= high]
print(q1, q2, q3) # 7 12.5 18
print(iqr) # 11
print(low, high) # -9.5 34.5
print(outliers) # [40]
print(min(inside), max(inside)) # 3 21The last line previews the next section: the whiskers of the boxplot end at 3 and 21, not at the fences.
How outliers appear on a boxplot
On a boxplot that marks outliers, the box still runs from Q1 to Q3 with a line at the median. The whiskers change meaning:
- The upper whisker extends to the largest data value that is at or below the upper fence.
- The lower whisker extends to the smallest data value that is at or above the lower fence.
- Any value beyond a fence is drawn as its own dot or star, separate from the whisker.
So a whisker ends at an actual data value, not at the fence itself. In the second example, the upper whisker ends at 21 and a separate dot sits at 40. The fences are invisible calculation tools. They usually do not appear in the picture.
How outliers affect other statistics
Some summary statistics are resistant, which means a single extreme value barely moves them. Others are sensitive. Compare the first data set with the second, which has 40 added.
| Statistic | Without 40 | With 40 | Change |
|---|---|---|---|
| Median | 12 | 12.5 | 0.5 |
| Q1 | 6 | 7 | 1 |
| Q3 | 16 | 18 | 2 |
| IQR | 10 | 11 | 1 |
| Range | 18 | 37 | 19 |
| Mean | about 11.2 | 14.1 | about 2.9 |
The range more than doubles because it depends only on the two extreme values. The mean moves by almost 3. The median and the IQR barely change, because they depend on positions in the ordered list rather than on how far away the extreme values are. This is why the median and IQR are the preferred summaries when a data set might contain outliers.
The table also shows that adding a value shifts the quartiles slightly, since the list is now longer and the halves are re-split. An outlier does not leave Q1 and Q3 completely untouched.
Edge cases and judgment
- Values exactly on a fence. The rule says "beyond" the fence. A value equal to the fence is not an outlier.
- Outliers on both sides. A data set can have outliers at the low end, the high end, or both. Check each fence separately.
- More than one outlier. Test every value. Several extreme values can all be flagged, and the whisker then ends at the most extreme value that is not flagged.
- Removing an outlier changes the quartiles. If a problem asks what happens after an outlier is deleted, recompute the halves from the shorter list. Do not reuse the old Q1 and Q3 without checking.
- Different quartile methods. Textbooks and software sometimes compute Q1 and Q3 slightly differently, which can shift the fences. GRE problems are designed so the method you learned here gives the intended answer, and they often give the quartiles directly.
- Outlier does not mean error. The rule only flags values that are far from the middle half. A flagged value may be a data entry mistake, or it may be a real and important observation. The rule cannot tell which.
Common errors
- Using the range or the standard deviation instead of the IQR to set the fences. The rule uses the IQR.
- Stopping at the fence value. The fence is a cutoff, not a data point. The whisker ends at the nearest actual data value inside the fence.
- Calling any large value an outlier. A value is an outlier only if it passes the fence. A value can be the maximum and still be an ordinary value.
- Checking only the high side. A low outlier is just as possible.
- Treating the box as holding most of the data. The box holds the middle half of the values, and each whisker region holds about a quarter, regardless of how long it looks. A long whisker does not mean more data.
Worked problem
A set of 11 delivery times, in minutes, is 12, 14, 15, 15, 16, 17, 18, 19, 21, 22, 48. Is 48 an outlier under the 1.5 x IQR rule?
The median is the 6th value, 17. The lower half is 12, 14, 15, 15, 16, so Q1 = 15. The upper half is 18, 19, 21, 22, 48, so Q3 = 21. Then IQR = 21 − 15 = 6 and 1.5 × 6 = 9. The upper fence is 21 + 9 = 30. Since 48 > 30, it is an outlier. The lower fence is 15 − 9 = 6, and the smallest value, 12, is above it, so there is no low outlier.
Exercise
A data set has Q1 = 20 and Q3 = 32. A student says that the value 52 is an outlier under the 1.5 x IQR rule. Is the student correct? Also, would the value 2 be an outlier?
Show answer
IQR = 32 − 20 = 12, and 1.5 × 12 = 18. The upper fence is 32 + 18 = 50, and 52 > 50, so 52 is an outlier and the student is correct. The lower fence is 20 − 18 = 2. The value 2 is exactly on the fence, not below it, so it is not an outlier.
Exercise
The ordered data set 4, 6, 7, 9, 10, 11, 13, 14, 30 is plotted as a boxplot that marks outliers by the 1.5 x IQR rule. Find the end of each whisker and say which values, if any, are drawn as separate points.
Show answer
There are 9 values, so the median is 10. The lower half is 4, 6, 7, 9, so Q1 = (6 + 7) / 2 = 6.5. The upper half is 11, 13, 14, 30, so Q3 = (13 + 14) / 2 = 13.5. IQR = 7 and 1.5 × 7 = 10.5. The fences are 6.5 − 10.5 = −4 and 13.5 + 10.5 = 24. The value 30 is above 24, so it is drawn as a separate point. The upper whisker ends at 14, the largest value inside the fence. The lower whisker ends at 4, the smallest value, because 4 is above −4.
Exercise
A data set has an outlier at the high end. If that single outlier is removed, which is more likely to change a lot: the range or the median? Explain briefly.
Show answer
The range is more likely to change a lot. The range depends directly on the largest value, so removing a far-away maximum can shrink the range sharply. The median depends only on the middle position in the ordered list, so removing one value from the end shifts it by at most half a step between neighboring values.