Quartiles, the IQR and outliers explained with examples
The average can be dragged around by a few extreme values. Quartiles describe the middle of your data in a way that resists that, and they give a simple rule for spotting values that do not fit.
The five-number summary
Sort the numbers from smallest to largest. Then pick out five values: the minimum, the first quartile (Q1), the median (also called Q2), the third quartile (Q3) and the maximum.
Q1 is the value with a quarter of the data below it. The median has half below. Q3 has three quarters below. Together they split the sorted data into four parts of roughly equal size.
Finding quartiles by hand
Take the data 1, 2, 3, 4, 5, 6, 7, 8, 9. The median is 5, the middle value. Now look at the lower half and the upper half.
- Sort the numbers.
- Find the median of the whole list. Here it is 5.
- Q1 is the median of the lower half, 1, 2, 3, 4, which is 2.5.
- Q3 is the median of the upper half, 6, 7, 8, 9, which is 7.5.
Why different tools give different answers
There is no single agreed way to deal with the middle value when the count is odd, so several methods are in use. For the data above:
- Halves without the median, the common textbook method, gives Q1 = 2.5 and Q3 = 7.5.
- Halves with the median included gives Q1 = 3 and Q3 = 7.
- The interpolated method used by Excel QUARTILE.INC also gives Q1 = 3 and Q3 = 7 here, but it can differ on other data because it interpolates between values.
The interquartile range
The interquartile range (IQR) is Q3 minus Q1. It is the spread of the middle half of the data. Unlike the plain range, which depends on the two most extreme values, the IQR hardly moves when an outlier is added.
The 1.5 x IQR rule for outliers
A common test for outliers, popularised by the statistician John Tukey, sets fences at Q1 minus 1.5 times the IQR and at Q3 plus 1.5 times the IQR. Values outside the fences are flagged.
Try the data 3, 5, 7, 8, 9, 11, 15, 16, 20, 21, 100 with the textbook method. Q1 is 7, Q3 is 20, so the IQR is 13. The upper fence is 20 + 19.5 = 39.5, and 100 lies far beyond it, so it is flagged as an outlier.
What to do with an outlier
- Check whether it is a typing mistake, such as an extra zero.
- If it is real, keep it, but consider reporting the median and IQR instead of the mean and standard deviation.
- Do not delete values just because they are inconvenient. Say that you removed them, and why.
Box plots
A box plot draws the five-number summary: a box from Q1 to Q3 with a line at the median, whiskers reaching out to the furthest values inside the fences, and dots for outliers.
Use the calculator
Paste your numbers into the quartile calculator, choose the method your course or software uses, and it shows Q1, the median, Q3, the IQR, the fences and any outliers. For a measure that uses every value, see the standard deviation calculator.