Mean, median, quartiles and mode of grouped data
🖨 Print a self-study sheet Why print?
In the previous lesson, students in grade 11 were asked how long their journey to school takes, and the data were grouped into a table:
| Time (minutes) | |||||
|---|---|---|---|---|---|
| Students |
Suppose the raw values have been lost and only this table is left. How long does the journey take on average? What time do half of the students not exceed? What time is the most common? In grade 10 we answered such questions with the mean, median, quartiles and mode. This lesson shows how to estimate them when only grouped data are available.
The mean
Explore: replacing each value by the representative value
We do not know the exact values for the students in the class , but we know they take from up to but not including minutes. If we treat each student in the class as taking exactly the representative time of minutes, then these students together contribute minutes to the total. Doing the same for the other classes and dividing by the number of students gives an estimate of the mean.
Each representative value is multiplied by the frequency of its class, so a crowded class counts for more. This formula can also be written \bar{x}=f_1c_1+\dots+f_kc_k, where f_i=\dfrac{m_i}{n} is the relative frequency (as a decimal).
The median and the quartiles
Explore: finding the halfway point using cumulative frequencies
The median splits the sample into two equal halves. For n=40 we need the value below which \dfrac n2=20 students lie. The cumulative frequencies of the classes are 6, 20, 32, 38, 40. Since 6<20\le20, the halfway point lies in the class [10, 20), the first class whose cumulative frequency is not less than 20. Before this class there are only 6 students, so we need 20-6=14 more students out of the 14 in the class: all of the class. The halfway point is the upper boundary 20.
In general, if the class containing the halfway point has m_p students, of which we need \dfrac n2-C_{p-1}, and we assume the students in the class are spread evenly, then we move from the lower boundary a_p by the fraction \dfrac{n/2-C_{p-1}}{m_p} of the class width.
When \dfrac{rn}{4} is exactly equal to a cumulative frequency, choosing that class or the next one gives the same result: the boundary the two classes share.
The mode
The mode is the most frequent value. For grouped data we find the class with the greatest frequency, called the modal class, and then choose a point inside it. This point is not necessarily the representative value: it is pulled towards the neighbouring class that is more crowded, because the data are denser there.
If m_{j-1} equals m_{j+1}, the fraction is \dfrac12 and the mode is the midpoint of the class. If the previous class is more crowded than the next one (m_{j-1}>m_{j+1}), the fraction is less than \dfrac12 and the mode moves towards the lower boundary.
Now we compute all four numbers for a real-life problem and see what they say.
Connections. The formulas in this lesson are built on the representative values and cumulative frequencies of the previous lesson, and take their ideas from how we found the mean, median, quartiles and mode in grade 10. The mean tells us the "centre" of the data in the sense of a total, the median splits the sample in half, and the mode points to the most crowded region. When we also need to know how widely the data are spread, we use measures of spread, which follow on from these measures of central tendency.
Key terms
Summary
- Mean: \bar{x}=\dfrac{m_1c_1+\dots+m_kc_k}{n}, where c_i is the representative value and m_i is the frequency of class i.
- The rth quartile: Q_r=a_p+\dfrac{\frac{rn}{4}-C_{p-1}}{m_p}\cdot(a_{p+1}-a_p), where [a_p, a_{p+1}) is the first class with C_p\ge\dfrac{rn}{4}; the median is M_e=Q_2.
- Mode: M_o=u_j+\dfrac{m_j-m_{j-1}}{(m_j-m_{j-1})+(m_j-m_{j+1})}\cdot h, where [u_j, u_{j+1}) is the class with the greatest frequency.
- These values are only estimates of the numbers computed from raw data, because we assume the data in each class are spread evenly.
- The mean is strongly affected by outliers; the median and quartiles are affected less.
Practice
Each exercise comes with what you need and hints. Try it yourself first, then open the solution.
The heights of 40 students are grouped: [150, 155) has 4, [155, 160) has 10, [160, 165) has 14, [165, 170) has 9, [170, 175) has 3 students. Estimate the mean height (to 1 decimal place).
What you need: \bar{x}=\dfrac{m_1c_1+\dots+m_kc_k}{n}.
Steps:
- Write the representative value of each class.
- Multiply by the frequencies, add, and divide by 40.
Show solution
For grouped data, the representative value of each class is its midpoint: 152.5; 157.5; 162.5; 167.5; 172.5. The sample size is n=4+10+14+9+3=40.
Using the formula for the mean of grouped data \bar{x}=\dfrac{m_1c_1+\dots+m_kc_k}{n}, we have \bar{x}=\frac{4\cdot152.5+10\cdot157.5+14\cdot162.5+9\cdot167.5+3\cdot172.5}{40}=\frac{6485}{40}\approx162.1.
So the estimated mean height is about 162.1 cm.
Answer. About 162.1 cm.
For the height table of the previous exercise, estimate the median, Q_1 and Q_3 (to 2 decimal places).
What you need: Q_r=a_p+\dfrac{\frac{rn}{4}-C_{p-1}}{m_p}\cdot h, where p is the first class with C_p\ge\dfrac{rn}{4}.
Steps:
- Find the cumulative frequencies: 4, 14, 28, 37, 40.
- Find the classes containing 10, 20, 30, then apply the formula.
Show solution
The sample size is n=40. The cumulative frequencies of the classes are 4, 14, 28, 37, 40.
Median: \dfrac n2=20. Since C_2=14<20\le C_3=28, the median class is [160, 165), with a_3=160, m_3=14, h=5. Hence M_e=160+\frac{20-14}{14}\cdot5\approx162.14.
First quartile: \dfrac n4=10. Since C_1=4<10\le C_2=14, the class containing Q_1 is [155, 160), with m_2=10. Hence Q_1=155+\frac{10-4}{10}\cdot5=158.
Third quartile: \dfrac{3n}{4}=30. Since C_3=28<30\le C_4=37, the class containing Q_3 is [165, 170), with m_4=9. Hence Q_3=165+\frac{30-28}{9}\cdot5\approx166.11.
So M_e\approx162.14 cm; Q_1=158 cm; Q_3\approx166.11 cm.
Answer. M_e\approx162.14; Q_1=158; Q_3\approx166.11 (cm).
For the height table of the previous exercises, estimate the mode (to 2 decimal places).
What you need: M_o=u_j+\dfrac{m_j-m_{j-1}}{(m_j-m_{j-1})+(m_j-m_{j+1})}\cdot h.
Steps:
- Find the class with the greatest frequency and the two neighbouring frequencies.
- Substitute into the formula.
Show solution
The class with the greatest frequency is [160, 165) with m_j=14; its neighbouring classes have frequencies m_{j-1}=10 and m_{j+1}=9. The class width is h=5.
Using the formula for the mode M_o=a_j+\frac{m_j-m_{j-1}}{(m_j-m_{j-1})+(m_j-m_{j+1})}\cdot h, we have M_o=160+\frac{14-10}{(14-10)+(14-9)}\cdot5=160+\frac49\cdot5\approx162.22.
So the estimated mode is about 162.22 cm.
Answer. M_o\approx162.22 cm.
Suppose the monthly water use (in \text{m}^3) of 50 households is grouped: [0, 5) has 4 households, [5, 10) has 16, [10, 15) has 18, [15, 20) has 9, [20, 25) has 3. Estimate the mean, median and mode (to 2 decimal places).
What you need: the three formulas of the lesson; the cumulative frequencies are 4, 20, 38, 47, 50.
Steps:
- Find \bar{x} using the representative values 2.5; 7.5; \dots.
- For the median, find the class containing \dfrac n2=25.
- The mode lies in the class with 18 households.
Show solution
The sample size is n=4+16+18+9+3=50. The representative values are 2.5; 7.5; 12.5; 17.5; 22.5. The cumulative frequencies are 4, 20, 38, 47, 50.
Mean: \bar{x}=\frac{4\cdot2.5+16\cdot7.5+18\cdot12.5+9\cdot17.5+3\cdot22.5}{50}=\frac{580}{50}=11.6.
Median: \dfrac n2=25. Since C_2=20<25\le C_3=38, the median class is [10, 15), with m_3=18, h=5. Hence M_e=10+\frac{25-20}{18}\cdot5\approx11.39.
Mode: the class with the greatest frequency is [10, 15) with m_j=18; its neighbouring classes have frequencies 16 and 9. Hence M_o=10+\frac{18-16}{(18-16)+(18-9)}\cdot5=10+\frac{2}{11}\cdot5\approx10.91.
So \bar{x}=11.60; M_e\approx11.39; M_o\approx10.91 (in \text{m}^3).
Answer. \bar{x}=11.60; M_e\approx11.39; M_o\approx10.91 (\text{m}^3).
The waiting times (in minutes) for a bus of 25 passengers are grouped: [0, 5) has 7, [5, 10) has 10, [10, 15) has 6, [15, 20) has 2 passengers. Estimate the median and Q_3 (to 2 decimal places). How should we interpret Q_3 in this situation?
What you need: the cumulative frequencies are 7, 17, 23, 25; \dfrac n2=12.5 and \dfrac{3n}{4}=18.75.
Steps:
- Find the first class with C_p\ge12.5, then the first with C_p\ge18.75.
- Apply the formula.
Show solution
The sample size is n=7+10+6+2=25. The cumulative frequencies are 7, 17, 23, 25.
Median: \dfrac n2=12.5. Since C_1=7<12.5\le C_2=17, the median class is [5, 10), with m_2=10, h=5. Hence M_e=5+\frac{12.5-7}{10}\cdot5=7.75.
Third quartile: \dfrac{3n}{4}=18.75. Since C_2=17<18.75\le C_3=23, the class containing Q_3 is [10, 15), with m_3=6. Hence Q_3=10+\frac{18.75-17}{6}\cdot5\approx11.46.
Meaning of Q_3: about \dfrac34 of the passengers wait no more than 11.46 minutes, or about a quarter of the passengers wait longer than that.
So the median is 7.75 minutes and Q_3\approx11.46 minutes.
Answer. M_e=7.75 minutes; Q_3\approx11.46 minutes.
Take grouped data: [0, 10) has 5, [10, 20) has x, [20, 30) has 15, [30, 40) has 5. The estimated mean is 20. Find x.
What you need: n=25+x; the representative values are 5, 15, 25, 35.
Steps:
- Write \bar{x} in terms of x.
- Solve the equation \bar{x}=20.
Show solution
The representative values of the four classes are 5, 15, 25, 35. The sample size is n=5+x+15+5=25+x (with x a positive integer).
The estimated mean is \bar{x}=\frac{5\cdot5+15x+25\cdot15+35\cdot5}{25+x}=\frac{575+15x}{25+x}.
By hypothesis \bar{x}=20, so \frac{575+15x}{25+x}=20\iff575+15x=500+20x\iff5x=75\iff x=15.
The value x=15 is a positive integer, so it is valid.
So x=15.
Answer. x=15.
The daily takings (in millions of dong) of a shop over 30 days are grouped: [10, 15) has 4 days, [15, 20) has 9 days, [20, 25) has 10 days, [25, 30) has 5 days, [30, 35) has 2 days. Decide whether each statement is true or false.
a) Q_1 lies in the class [15, 20).
b) The median is M_e=21.
c) The estimated mean is \bar{x}\approx21.17.
d) The mode is M_o=22.5.
What you need: the cumulative frequencies are 4, 13, 23, 28, 30; \dfrac n4=7.5, \dfrac n2=15.
Steps:
- a) Find the first class with C_p\ge7.5.
- b) Find M_e in the class [20, 25).
- c), d) Find \bar{x} and M_o.
Show solution
The sample size is n=4+9+10+5+2=30. The cumulative frequencies are 4, 13, 23, 28, 30. The class width is h=5.
a) True. We have \dfrac n4=7.5 and C_1=4<7.5\le C_2=13, so Q_1 lies in the class [15, 20).
b) True. We have \dfrac n2=15 and C_2=13<15\le C_3=23, so the median class is [20, 25) with m_3=10. Hence M_e=20+\frac{15-13}{10}\cdot5=21.
c) True. The representative values are 12.5; 17.5; 22.5; 27.5; 32.5. Hence \bar{x}=\frac{12.5\cdot4+17.5\cdot9+22.5\cdot10+27.5\cdot5+32.5\cdot2}{30}=\frac{635}{30}\approx21.17.
d) False. The class with the greatest frequency is [20, 25) with m_j=10; its neighbouring classes have frequencies 9 and 5. Hence M_o=20+\frac{10-9}{(10-9)+(10-5)}\cdot5=20+\frac16\cdot5\approx20.83. The value 22.5 is only the representative value of the class [20, 25), not the mode.
So statements a), b), c) are true; statement d) is false.
Answer. a) True; b) True; c) True; d) False.
A grouped data set of size 40 has cumulative frequency 12 for the class [10, 20), and the class [20, 30) has frequency 16. Estimate the median.
What you need: \dfrac n2=20 lies in the class [20, 30) because 12<20\le12+16.
Steps:
- Identify a_p, C_{p-1}, m_p.
- Substitute into the formula for M_e.
Show solution
The sample size is n=40, so \dfrac n2=20. The cumulative frequency of the class [10, 20) is 12 and the class [20, 30) has frequency 16, so the cumulative frequency of the class [20, 30) is 12+16=28. Since 12<20\le28, the median class is [20, 30).
We have a_p=20, C_{p-1}=12, m_p=16 and h=10. Using the median formula M_e=a_p+\frac{\frac n2-C_{p-1}}{m_p}\cdot h, we get M_e=20+\frac{20-12}{16}\cdot10=20+5=25.
So the estimated median is 25.
Answer. M_e=25.
Use the relative frequencies of the journey-time table of the previous lesson (15\%, 35\%, 30\%, 15\%, 5\%) and the representative values 5, 15, 25, 35, 45 to find the mean again by the formula \bar{x}=f_1c_1+\dots+f_kc_k.
What you need: f_i=\dfrac{m_i}{n}, so \dfrac{m_ic_i}{n}=f_ic_i; convert the percentages to decimals.
Steps:
- Write 0.15; 0.35; 0.30; 0.15; 0.05.
- Multiply by the representative values and add.
Show solution
The relative frequencies add up to 15\%+35\%+30\%+15\%+5\%=100\%. As decimals: f_1=0.15, f_2=0.35, f_3=0.30, f_4=0.15, f_5=0.05. The representative values are c_1=5, c_2=15, c_3=25, c_4=35, c_5=45.
Using the formula \bar{x}=f_1c_1+\dots+f_kc_k, we have \begin{aligned}\bar{x}&=0.15\cdot5+0.35\cdot15+0.30\cdot25+0.15\cdot35+0.05\cdot45\\&=0.75+5.25+7.5+5.25+2.25\\&=21.\end{aligned}
So the mean is 21 minutes, the same result as with the frequencies.
Answer. \bar{x}=21 minutes, the same result as with the frequencies.
Grouped data have k classes of the same width h, all with the same frequency. Prove that the estimated mean is the midpoint of the interval [a_1, a_{k+1}], where a_1 is the lower boundary of the first class and a_{k+1} the upper boundary of the last class.
What you need: the representative values form an arithmetic progression with common difference h (previous lesson); the sum of the first k terms of an arithmetic progression is S_k=\dfrac{k(c_1+c_k)}{2}.
Steps:
- With equal frequencies m, n=km and \bar{x}=\dfrac{c_1+\dots+c_k}{k}.
- Use c_1=a_1+\dfrac h2 and c_k=a_{k+1}-\dfrac h2.
Show solution
The classes are [a_1, a_2), [a_2, a_3), \dots, [a_k, a_{k+1}) with a_{i+1}-a_i=h. The representative value of the ith class is c_i=\dfrac{a_i+a_{i+1}}{2}.
Let m be the common frequency of each class. Then the sample size is n=km and \bar{x}=\frac{m\left(c_1+c_2+\dots+c_k\right)}{km}=\frac{c_1+c_2+\dots+c_k}{k}.
The values c_1, c_2,\dots,c_k are equally spaced with difference h, so they form an arithmetic progression. Hence c_1+c_2+\dots+c_k=\frac{k\left(c_1+c_k\right)}{2}, and so \bar{x}=\dfrac{c_1+c_k}{2}.
We have c_1=a_1+\dfrac h2 and c_k=a_{k+1}-\dfrac h2 (since the last class is [a_k, a_{k+1}) with a_k=a_{k+1}-h). Therefore \bar{x}=\frac{\left(a_1+\frac h2\right)+\left(a_{k+1}-\frac h2\right)}{2}=\frac{a_1+a_{k+1}}{2}.
So the estimated mean equals the midpoint of the interval [a_1, a_{k+1}].
Answer. \bar{x}=\dfrac{a_1+a_{k+1}}{2}, the midpoint of [a_1, a_{k+1}].
Mini test
Marked like the Vietnamese graduation exam: Part I 0.25 points per question; Part II up to 1 point per question (1, 2, 3, 4 correct statements give 0.1, 0.25, 0.5, 1 point); Part III 0.5 points per question.
Part I. Multiple choice
\bar{x}=\dfrac{2\cdot5+3\cdot15+5\cdot25}{10}=\dfrac{180}{10}=18. Option A is the plain mean of the three representative values (forgetting the frequencies), and option C forgets to divide by n.
The cumulative frequencies are 15, 18, 21, 24, 40 and \dfrac n2=20, so the first class with C_p\ge20 is the third class. Option C is the class with the greatest frequency.
M_o=10+\dfrac{10-4}{(10-4)+(10-6)}\cdot10=16. Option A is the representative value, option C swaps the roles of the two neighbouring classes, and option D is the upper boundary.
\dfrac n4=10, class [10, 20) (C_1=5, m_2=10): Q_1=10+\dfrac{10-5}{10}\cdot10=15. Option A is C_1, option B is \dfrac n4, and option D is the upper boundary of the class.
Part II. True or false
| a) The estimated mean is 30. | ||
| b) The class containing Q_3 is [40, 60). | ||
| c) The median is M_e\approx33.3. | ||
| d) Q_1=20. |
The cumulative frequencies are 10, 40, 60. a) False: \bar{x}=\dfrac{10\cdot10+30\cdot30+20\cdot50}{60}\approx33.3; 30 is the plain mean of the representative values. b) True: \dfrac{3n}{4}=45>40. c) True: M_e=20+\dfrac{30-10}{30}\cdot20\approx33.3. d) False: Q_1=20+\dfrac{15-10}{30}\cdot20\approx23.3.
Part III. Short answer
\bar{x}=\dfrac{3\cdot2.5+7\cdot7.5}{10}=\dfrac{60}{10}=6.
\dfrac{3n}{4}=30; the cumulative frequencies are 5, 15, 30, 40, so the class is [20, 30) (C_2=15, m_3=15): Q_3=20+\dfrac{30-15}{15}\cdot10=30.
Show answers and explanations
- Part I, question 1: D. \bar{x}=\dfrac{2\cdot5+3\cdot15+5\cdot25}{10}=\dfrac{180}{10}=18. Option A is the plain mean of the three representative values (forgetting the frequencies), and option C forgets to divide by n.
- Part I, question 2: A. The cumulative frequencies are 15, 18, 21, 24, 40 and \dfrac n2=20, so the first class with C_p\ge20 is the third class. Option C is the class with the greatest frequency.
- Part I, question 3: B. M_o=10+\dfrac{10-4}{(10-4)+(10-6)}\cdot10=16. Option A is the representative value, option C swaps the roles of the two neighbouring classes, and option D is the upper boundary.
- Part I, question 4: C. \dfrac n4=10, class [10, 20) (C_1=5, m_2=10): Q_1=10+\dfrac{10-5}{10}\cdot10=15. Option A is C_1, option B is \dfrac n4, and option D is the upper boundary of the class.
- Part II, question 1: a) False; b) True; c) True; d) False. The cumulative frequencies are 10, 40, 60. a) False: \bar{x}=\dfrac{10\cdot10+30\cdot30+20\cdot50}{60}\approx33.3; 30 is the plain mean of the representative values. b) True: \dfrac{3n}{4}=45>40. c) True: M_e=20+\dfrac{30-10}{30}\cdot20\approx33.3. d) False: Q_1=20+\dfrac{15-10}{30}\cdot20\approx23.3.
- Part III, question 1: 6. \bar{x}=\dfrac{3\cdot2.5+7\cdot7.5}{10}=\dfrac{60}{10}=6.
- Part III, question 2: 30. \dfrac{3n}{4}=30; the cumulative frequencies are 5, 15, 30, 40, so the class is [20, 30) (C_2=15, m_3=15): Q_3=20+\dfrac{30-15}{15}\cdot10=30.