Range and quartiles · Statistics & Data Science | StemPy Lab
Course 2.3·Lesson 1 of 3
Range and quartiles
The range is the largest value minus the smallest, but one extreme value can make it huge. The quartiles split sorted data into four equal parts: Q1 is the median of the lower half and Q3 is the median of the upper half. The interquartile range, Q3 minus Q1, is the width of the middle half, and a box plot draws it.
about 35 min1 simulation2 practice questions2 Python programs6 questions to check yourself
This lesson is free to read. Enroll free to keep your place and take the tests.
Lesson 1 of 3Show all lessonsHide
Try the code and the simulations beside the lesson.
The same mean, but not the same
Two teams have the same mean score of 50 points. Team A scores 48,50,52,49,51. Team B scores 20,80,50,35,65. The mean says that they are equal. Are they?
Two rows of dots on a number line from 20 to 80. Team A has five dots very close together around 50, with a range of 4. Team B has five dots far apart, at 20, 35, 50, 65 and 80, with a range of 60. A red line at 50 shows that both teams have the same mean, 50.
The spread of data tells us how far apart the values are. The mean tells us where the data is. The spread tells us how much it varies.
Try it in Python
The range
The range is the largest value minus the smallest value.
range=largest−smallest
It is quick, but it looks at only two values. One extreme value can make the range huge, even when all the other values are close together.
The quartiles
The median splits sorted data into two halves. The quartiles split it into four equal parts.
Sort the data.
Find the median. This is the middle quartile, Q2.
Q1 is the median of the lower half.
Q3 is the median of the upper half.
If the number of values is odd, leave the middle value out of both halves.
Eight boxes in a row hold the sorted values 3, 5, 7, 8, 12, 13, 14 and 18. The first four boxes are the lower half and the last four are the upper half. An arrow marks Q1 equal to 6, the middle of the lower half. An arrow marks the median, 10, between 8 and 12. An arrow marks Q3 equal to 13.5, the middle of the upper half. A double arrow from Q1 to Q3 shows the interquartile range, 13.5 minus 6, which is 7.5.
The interquartile range (IQR) is the width of the middle half of the data.
IQR=Q3−Q1
For the eight values in the picture, Q1=6 and Q3=13.5, so the IQR is 13.5−6=7.5. One extreme value hardly changes the IQR, because the extreme values sit in the halves, not in the middle.
The box plot
A box plot draws five numbers: the smallest value, Q1, the median, Q3 and the largest value. The box holds the middle half of the data. The lines on each side, the whiskers, reach to the smallest and the largest values.
A box plot on a number line from 0 to 20. A line runs from the smallest value, 3, to the largest value, 18. A box runs from Q1, 6, to Q3, 13.5, with a thick red line at the median, 10. A note says that the box holds the middle half of the data, and its width is the interquartile range, 7.5. Another note says that the whole line is the range, 15.
You should find that the box never moves, however far out you pull the two ends. The range follows the ends; the IQR stays 7.5.
Practise with new numbers
Common mistakes
Forgetting to sort before finding the quartiles.
Using the range when there is an outlier. One extreme value makes it huge.
Keeping the median in a half when the count is odd. Leave it out of both halves.
Giving Q3 as the IQR. The IQR is Q3−Q1, a width.
Remember these
Range = largest minus smallest. One extreme value can make it huge.
Q1 is the median of the lower half, and Q3 is the median of the upper half.
IQR = Q3 minus Q1, the width of the middle half.
A box plot shows the smallest value, Q1, the median, Q3 and the largest value.
Check yourself
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
What is the range of 4,9,15 and 6?
For the sorted values 2,4,6,8,10,12,14, what are Q1 and Q3?
A box plot has the five numbers 5, 12, 18, 22 and 40. What is the IQR?
Why does one very large value change the range but hardly the IQR?
Enroll free in Spread
Every lesson is open to read. Enrolling also lets you:
Mark lessons done and carry on where you stopped.
Take the tests of this lesson and its course.
Count the course towards the certificate for its chapter.