The quartiles cut ordered data into four equal parts. The distance between the first and third quartile is the interquartile range, a spread that one odd reading cannot ruin. A box plot draws the five-number summary, and a fence rule marks outliers.
about 30 min1 simulation1 practice question
Lesson 3 of 3Show all lessonsHide
Try the code and the simulations beside the lesson.
What you will be able to do
find the quartiles and the interquartile range of a list of data;
draw and read a box plot from the five-number summary;
use the fence rule to find outliers, and say how they affect the mean and the standard deviation.
Splitting the data into quarters
The median splits ordered data into two halves. Now split each half again. The three cut points are the quartiles.
The lower quartileQ1 has a quarter of the data below it.
The medianQ2 has half of the data below it.
The upper quartileQ3 has three quarters of the data below it.
How to find them
There are several rules for the quartiles, and they can differ a little for a small data set. This chapter uses the rule that most textbooks and many calculators use.
Sort the data and find the median.
Make a lower half and an upper half. If the number of values is odd, leave the median out of both halves.
Q1 is the median of the lower half. Q3 is the median of the upper half.
Take twelve readings in order: 8,9,11,12,13,14, then 15,16,18,19,21,48. The median is 214+15=14.5. The lower half is 8,9,11,12,13,14, so Q1=211+12=11.5. The upper half is 15,16,18,19,21,48, so Q3=218+19=18.5.
A word of caution. Spreadsheet programs and the default setting of numpy interpolate between values and give 11.75 and 18.25 for the same data. Some A-Level boards use a position rule that rounds up. A question will either state the rule, or choose data where the rules agree. When in doubt, say which rule you used.
The interquartile range
The interquartile range is
IQR=Q3−Q1.
It is the width of the middle half of the data. For the twelve readings it is 18.5−11.5=7. Unlike the range and the standard deviation, it is not affected by the value 48. Some Indian books use half of it, the quartile deviation2Q3−Q1, and the coefficient of quartile deviationQ3+Q1Q3−Q1.
If every value is multiplied by a, the IQR is multiplied by ∣a∣. If a number is added to every value, the IQR does not change.
The five-number summary and the box plot
The five-number summary is the smallest value, Q1, the median, Q3 and the largest value. A box plot (also called a box-and-whisker diagram) draws it:
a box from Q1 to Q3, with a line at the median;
whiskers that run from the box to the smallest and the largest values that are not outliers;
a cross for each outlier.
Outliers
An outlier is a value that lies far from the rest. The most common rule uses fences:
lower fence=Q1−1.5IQR,upper fence=Q3+1.5IQR.
A value below the lower fence or above the upper fence is an outlier. The twelve readings have fences at 11.5−10.5=1 and 18.5+10.5=29. So 48 is an outlier, and the right whisker stops at 21, the largest value inside the fence.
A-Level questions sometimes define an outlier as a value more than 2 standard deviations from the mean, or give their own rule. IB and AP use the 1.5IQR rule above.
A horizontal box plot of twelve readings from 8 to 48. The box runs from the first quartile 11.5 to the third quartile 18.5, with a red line at the median 14.5. The left whisker reaches the smallest value 8 and the right whisker reaches 21, the largest value inside the fence. A dashed vertical fence at 29 is labelled upper fence 29, and a red cross at 48 beyond it is labelled outlier. A green double arrow under the box is labelled IQR = 7.
What outliers do
An outlier pulls the mean and increases the standard deviation. The median, the quartiles and the IQR hardly notice it. For the twelve readings the mean is 17 with the outlier and 14.18 without it. That is why box plots and the median are used for data with a few extreme values. An outlier is not always a mistake. It may be a real, rare event. Check it before you remove it.
Practise with new numbers
Try it in Python
The program finds the quartiles, the IQR, the fences and the outliers of the twelve readings. It also shows what the default quartile rule of numpy gives.
Common mistakes
Keeping the median in both halves. For an odd number of values, leave the median out.
Forgetting the 1.5. The fences are 1.5 interquartile ranges from the quartiles.
Ending the whisker at the outlier. The whisker stops at the last value inside the fence.
Treating every outlier as an error. Check the source first.
Mixing the rules. Use one quartile rule throughout, and say which.
Remember these
Q1 and Q3 are the medians of the lower and the upper half. IQR=Q3−Q1.