Lemonmath
Tiếng Việt

Variance and standard deviation of grouped data

Lesson 3.2 · 22 min read · Updated

A factory has two machines that fill 11 kg bags of rice. Fifty bags from each machine were weighed and the masses (grams) were grouped:

Mass (g) [990,994)[990, 994) [994,998)[994, 998) [998,1002)[998, 1002) [1002,1006)[1002, 1006) [1006,1010)[1006, 1010)
Machine A 22 88 3030 88 22
Machine B 66 1010 1818 1010 66

Both tables are symmetric about 10001000 g, so the two machines have the same mean mass. Which machine fills more evenly, and by how much?

The previous lesson used the interquartile range, which looks only at the middle half of the data. This lesson uses every value, through the variance and the standard deviation.

The variance of grouped data

Exploring: how far off is each bag?

We do not know the true mass of each bag, so we replace each bag by the class midpoint of its class: 992992, 996996, 10001000, 10041004, 10081008. Compared with the mean 10001000, the deviations are −8-8, −4-4, 00, 44, 88.

For machine A, 22 bags deviate by −8-8, 88 bags by −4-4, and so on. Square the deviations (so the signs do not cancel), multiply by the frequencies and take the mean: 2⋅64+8⋅16+30⋅0+8⋅16+2⋅6450=51250=10.24.\frac{2\cdot64+8\cdot16+30\cdot0+8\cdot16+2\cdot64}{50}=\frac{512}{50}=10.24. This number measures how far the bags stray from 10001000 g. It is exactly the variance of the grouped data.

In this lesson, grouped data have kk classes with midpoints x1x_1, …, xkx_k, frequencies n1n_1, …, nkn_k, sample size nn and mean xˉ=n1x1+⋯+nkxkn\bar{x}=\dfrac{n_1x_1+\cdots+n_kx_k}{n} (grade 11).

Why are the two formulas equal? Expand (xi−xˉ)2=xi2−2xˉxi+xˉ2(x_i-\bar{x})^2=x_i^2-2\bar{x}x_i+\bar{x}^2, multiply by nin_i, add up and divide by nn. Since ∑nixin=xˉ\dfrac{\sum n_ix_i}{n}=\bar{x} and ∑nin=1\dfrac{\sum n_i}{n}=1, we get ∑nixi2n−2xˉ2+xˉ2\dfrac{\sum n_ix_i^2}{n}-2\bar{x}^2+\bar{x}^2, which is the second formula.

The standard deviation has the same unit as the data (grams here), so it is easier to interpret than the variance. The first formula is convenient when xˉ\bar{x} is a round number; the second is convenient when it is not.

Step by step with a table

When xˉ\bar{x} is not round, we draw up a table with the columns xix_i, nin_i, nixin_ix_i, nixi2n_ix_i^2 and use the second formula.

When xˉ\bar{x} is round, the definition gives small numbers that are easy to work with. The next example completes the exploration.

Comparing two data sets

For two data sets with similar means, the one with the smaller standard deviation is more even. Now we answer the opening question.

The effect of the class width

The standard deviation of grouped data uses midpoints instead of the true values, so it is only an approximate value of the standard deviation of the raw data. The narrower the classes, the closer the midpoints are to the true values.

Key terms

Summary

  • Replace each class by its midpoint xix_i with frequency nin_i.
  • s2=1n∑ni(xi−xˉ)2=1n∑nixi2−xˉ2s^2=\dfrac1n\sum n_i(x_i-\bar{x})^2=\dfrac1n\sum n_ix_i^2-\bar{x}^2; s=s2s=\sqrt{s^2}, in the same unit as the data.
  • Draw up a table of xix_i, nin_i, nixin_ix_i, nixi2n_ix_i^2; round only the final result.
  • For two data sets with similar means: smaller ss means more even.
  • The ss of grouped data is an approximate value; narrower classes usually give a better approximation.

Practice

Each exercise comes with what you need and some steps to start. Try it yourself first, then open the solution.

Exercise 1

The daily phone use (hours) of 2020 students is given in the table. Find s2s^2 and ss with the definition.

Time (hours) [0,4)[0, 4) [4,8)[4, 8) [8,12)[8, 12) [12,16)[12, 16)
Students 33 77 77 33
What you need and how to start

What you need: s2=1n∑ni(xi−xˉ)2s^2=\dfrac1n\sum n_i(x_i-\bar{x})^2 with xix_i the midpoints.

Steps:

  1. Midpoints 22, 66, 1010, 1414; find xˉ\bar{x}.
  2. Find the deviations, square them and multiply by the frequencies.
Show solution

xˉ=6+42+70+4220=8\bar{x}=\dfrac{6+42+70+42}{20}=8; the deviations are −6-6, −2-2, 22, 66. s2=3⋅36+7⋅4+7⋅4+3⋅3620=27220=13.6,s≈3.69.s^2=\frac{3\cdot36+7\cdot4+7\cdot4+3\cdot36}{20}=\frac{272}{20}=13.6,\qquad s\approx3.69.

Answer. s2=13.6s^2=13.6; s≈3.69s\approx3.69 hours.

Exercise 2

The test marks of 4040 students are grouped as follows. Draw up the table and find xˉ\bar{x}, s2s^2, ss.

Mark [4,5)[4, 5) [5,6)[5, 6) [6,7)[6, 7) [7,8)[7, 8) [8,9)[8, 9) [9,10)[9, 10)
Students 22 55 99 1414 77 33
What you need and how to start

What you need: s2=1n∑nixi2−xˉ2s^2=\dfrac1n\sum n_ix_i^2-\bar{x}^2.

Steps:

  1. Midpoints 4.54.5, 5.55.5, …, 9.59.5.
  2. Find ∑nixi\sum n_ix_i and ∑nixi2\sum n_ix_i^2.
Show solution

∑nixi=9+27.5+58.5+105+59.5+28.5=288\sum n_ix_i=9+27.5+58.5+105+59.5+28.5=288 and ∑nixi2=2136\sum n_ix_i^2=2136. xˉ=28840=7.2,s2=213640−7.22=53.4−51.84=1.56,s≈1.25.\bar{x}=\frac{288}{40}=7.2,\qquad s^2=\frac{2136}{40}-7.2^2=53.4-51.84=1.56,\qquad s\approx1.25.

Answer. xˉ=7.2\bar{x}=7.2; s2=1.56s^2=1.56; s≈1.25s\approx1.25.

Exercise 3

Two delivery services P and Q recorded the delivery times (minutes) of 4040 orders each.

Time (minutes) [20,25)[20, 25) [25,30)[25, 30) [30,35)[30, 35) [35,40)[35, 40) [40,45)[40, 45)
Service P 22 1010 1616 1010 22
Service Q 88 88 88 88 88

Find the mean time and the standard deviation for each service. Which service delivers more reliably on time?

What you need and how to start

What you need: with equal means, the smaller ss means more reliable.

Steps:

  1. Midpoints 22.522.5, 27.527.5, …, 42.542.5. Both tables are symmetric about 32.532.5.
  2. The deviations are −10-10, −5-5, 00, 55, 1010.
Show solution

Both have xˉ=32.5\bar{x}=32.5 minutes. P: s2=2⋅100+10⋅25+0+10⋅25+2⋅10040=90040=22.5, s≈4.74;\text{P: } s^2=\frac{2\cdot100+10\cdot25+0+10\cdot25+2\cdot100}{40}=\frac{900}{40}=22.5,\ s\approx4.74; Q: s2=8⋅(100+25+0+25+100)40=200040=50, s≈7.07.\text{Q: } s^2=\frac{8\cdot(100+25+0+25+100)}{40}=\frac{2000}{40}=50,\ s\approx7.07.

Answer. Mean 32.532.5 minutes; s≈4.74s\approx4.74 (P) and s≈7.07s\approx7.07 (Q). Service P is more reliable.

Exercise 4

Consider the following grouped data.

Class [0,10)[0, 10) [10,20)[10, 20) [20,30)[20, 30) [30,40)[30, 40)
Frequency 11 44 44 11

Is each claim true or false?

a) The mean is 2020.

b) The variance is 6565.

c) The standard deviation is greater than 99.

d) If every value is increased by 55 (the classes become [5,15)[5, 15), …, [35,45)[35, 45)), the variance becomes 7070.

What you need and how to start

What you need: the variance formula; adding the same number to every value leaves the deviations unchanged.

Steps:

  1. Midpoints 55, 1515, 2525, 3535; find xˉ\bar{x}.
  2. The deviations are −15-15, −5-5, 55, 1515.
Show solution

a) True. xˉ=5+60+100+3510=20\bar{x}=\dfrac{5+60+100+35}{10}=20.

b) True. s2=1⋅225+4⋅25+4⋅25+1⋅22510=65010=65s^2=\dfrac{1\cdot225+4\cdot25+4\cdot25+1\cdot225}{10}=\dfrac{650}{10}=65.

c) False. s=65≈8.06<9s=\sqrt{65}\approx8.06<9.

d) False. The midpoints and xˉ\bar{x} all increase by 55, so the deviations are unchanged and the variance is still 6565.

Answer. a) True; b) True; c) False; d) False.

Exercise 5

The heights (cm) of 5050 students are given in the table. Find the standard deviation (in cm, to two decimal places).

Height (cm) [150,155)[150, 155) [155,160)[155, 160) [160,165)[160, 165) [165,170)[165, 170) [170,175)[170, 175)
Students 55 1212 1818 1010 55
What you need and how to start

What you need: s2=1n∑nixi2−xˉ2s^2=\dfrac1n\sum n_ix_i^2-\bar{x}^2; do not round xˉ\bar{x} along the way.

Steps:

  1. Midpoints 152.5152.5, 157.5157.5, …, 172.5172.5.
  2. Find xˉ\bar{x}, then s2s^2; take the square root and round only at the end.
Show solution

∑nixi=8115\sum n_ix_i=8115, so xˉ=162.3\bar{x}=162.3; ∑nixi2=1318612.5\sum n_ix_i^2=1318612.5. s2=1318612.550−162.32=26372.25−26341.29=30.96,s≈5.564.s^2=\frac{1318612.5}{50}-162.3^2=26372.25-26341.29=30.96,\qquad s\approx5.564.

Answer. 5.565.56.

Exercise 6

(Revisiting the mean of grouped data, grade 11.) The times (minutes) that 2020 students took to finish an assignment are given in the table. Find xˉ\bar{x}, then ss.

Time (minutes) [10,20)[10, 20) [20,30)[20, 30) [30,40)[30, 40) [40,50)[40, 50)
Students 33 99 66 22
What you need and how to start

What you need: xˉ=∑nixin\bar{x}=\dfrac{\sum n_ix_i}{n} with xix_i the midpoints; s2=∑nixi2n−xˉ2s^2=\dfrac{\sum n_ix_i^2}{n}-\bar{x}^2.

Steps:

  1. Midpoints 1515, 2525, 3535, 4545.
  2. Find ∑nixi\sum n_ix_i and ∑nixi2\sum n_ix_i^2.
Show solution

xˉ=45+225+210+9020=57020=28.5,675+5625+7350+405020=1770020=885.\bar{x}=\frac{45+225+210+90}{20}=\frac{570}{20}=28.5,\qquad \frac{675+5625+7350+4050}{20}=\frac{17700}{20}=885. s2=885−28.52=885−812.25=72.75,s≈8.53.s^2=885-28.5^2=885-812.25=72.75,\qquad s\approx8.53.

Answer. xˉ=28.5\bar{x}=28.5 minutes; s≈8.53s\approx8.53 minutes.

Exercise 7

(Revisiting Range and interquartile range of grouped data.) For the two delivery services in Exercise 3, find the interquartile range of each. Is the conclusion the same as with the standard deviation?

What you need and how to start

What you need: Q1=um+n4−Cnm(um+1−um)Q_1=u_m+\dfrac{\frac n4-C}{n_m}(u_{m+1}-u_m), and likewise for Q3Q_3; positions 1010 and 3030.

Steps:

  1. Cumulative frequencies for P: 22, 1212, 2828, 3838, 4040; for Q: 88, 1616, 2424, 3232, 4040.
  2. Find Q1Q_1, Q3Q_3 for each service.
Show solution

P: Q1=25+10−210⋅5=29Q_1=25+\dfrac{10-2}{10}\cdot5=29, Q3=35+30−2810⋅5=36Q_3=35+\dfrac{30-28}{10}\cdot5=36, ΔQ=7\Delta_Q=7.

Q: Q1=25+10−88⋅5=26.25Q_1=25+\dfrac{10-8}{8}\cdot5=26.25, Q3=35+30−248⋅5=38.75Q_3=35+\dfrac{30-24}{8}\cdot5=38.75, ΔQ=12.5\Delta_Q=12.5.

Answer. ΔQ=7\Delta_Q=7 (P) and 12.512.5 (Q); the same conclusion as from the standard deviation: P is more reliable.

Exercise 8 Challenge

Grouped data have the following frequency table, where xx is a positive integer. The mean is 4.24.2. Find xx, then the variance (to two decimal places).

Class [0,2)[0, 2) [2,4)[2, 4) [4,6)[4, 6) [6,8)[6, 8)
Frequency 22 xx 55 33
What you need and how to start

What you need: xˉ=∑nixin\bar{x}=\dfrac{\sum n_ix_i}{n} with n=10+xn=10+x.

Steps:

  1. Midpoints 11, 33, 55, 77; set up the equation 48+3x10+x=4.2\dfrac{48+3x}{10+x}=4.2.
  2. With that xx, find ∑nixi2\sum n_ix_i^2 and s2s^2.
Show solution

2+3x+25+2110+x=4.2  ⟺  48+3x=42+4.2x  ⟺  1.2x=6  ⟺  x=5.\frac{2+3x+25+21}{10+x}=4.2\iff 48+3x=42+4.2x\iff 1.2x=6\iff x=5. Then n=15n=15 and ∑nixi2=2+45+125+147=319\sum n_ix_i^2=2+45+125+147=319: s2=31915−4.22=31915−17.64=27275≈3.63.s^2=\frac{319}{15}-4.2^2=\frac{319}{15}-17.64=\frac{272}{75}\approx3.63.

Answer. x=5x=5; s2≈3.63s^2\approx3.63.

Exercise 9 Challenge

In Example 1 the sleep data have s2=1.1275s^2=1.1275 (unit: hours²). If all the data are converted to minutes (every value and every class end multiplied by 6060), what are the new variance and standard deviation?

What you need and how to start

What you need: multiplying every value by kk multiplies xˉ\bar{x} and every deviation by kk.

Steps:

  1. Each deviation xi−xˉx_i-\bar{x} is multiplied by 6060, so its square is multiplied by 36003600.
  2. Deduce the new s2s^2, then the new ss.
Show solution

snew2=3600⋅1.1275=4059,snew=60⋅1.1275≈63.71.s^2_{\text{new}}=3600\cdot1.1275=4059,\qquad s_{\text{new}}=60\cdot\sqrt{1.1275}\approx63.71. (Check: 4059≈63.71\sqrt{4059}\approx63.71.)

Answer. s2=4059s^2=4059 (minutes²); s≈63.71s\approx63.71 minutes.

Mini test

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

Question 1. In grouped data, the class midpoint of the class [20,30)[20, 30) is
Question 2. A set of grouped data has variance s2=2.25s^2=2.25. Its standard deviation is
Question 3.

The variance of the following grouped data is

Class [0,2)[0, 2) [2,4)[2, 4) [4,6)[4, 6) [6,8)[6, 8)
Frequency 22 33 33 22
Question 4. Two sets of grouped data AA and BB have the same mean, with standard deviations sA=2.1s_A=2.1 and sB=3.4s_B=3.4. Which statement is correct?

Part II. True or false

Question 1.

The weekly running distances (km) of 2020 people are given in the table.

Distance (km) [10,20)[10, 20) [20,30)[20, 30) [30,40)[30, 40) [40,50)[40, 50)
People 44 66 88 22
a) The class midpoint of the class [30,40)[30, 40) is 3535.
b) The mean of the data is 2929 km.
c) The variance of the data is 8484.
d) If every value is converted to a different unit by multiplying by 22, the new variance is 168168.

Part III. Short answer

Question 1.

The weekly private study times (hours) of 3030 students are given in the table. Find the standard deviation of the data, giving your answer to 2 decimal places.

Time (hours) [0,3)[0, 3) [3,6)[3, 6) [6,9)[6, 9) [9,12)[9, 12)
Students 44 1010 1212 44

Question 2.

The lengths (mm) of 4040 machine parts are given in the table. Find the variance of the data, giving your answer to 2 decimal places.

Length (mm) [48,49)[48, 49) [49,50)[49, 50) [50,51)[50, 51) [51,52)[51, 52)
Parts 44 1616 1616 44

Show answers and explanations
  1. Part I, question 1: B. The class midpoint is the middle of the class: 20+302=25\dfrac{20+30}{2}=25. Options A and C are the class ends, and option D is the class width.
  2. Part I, question 2: D. s=s2=2.25=1.5s=\sqrt{s^2}=\sqrt{2.25}=1.5. Option B squares instead of taking the square root, and option A halves instead of taking the square root.
  3. Part I, question 3: A. The class midpoints are 11, 33, 55, 77 and xˉ=4\bar{x}=4; the deviations are −3-3, −1-1, 11, 33. s2=2⋅9+3⋅1+3⋅1+2⋅910=4.2s^2=\dfrac{2\cdot9+3\cdot1+3\cdot1+2\cdot9}{10}=4.2. Option B forgets the frequencies, option C is the standard deviation, and option D adds the deviations without squaring them.
  4. Part I, question 4: C. With the same mean, a smaller standard deviation means the data are less spread out. The standard deviation does not decide the range for certain, so A is wrong.
  5. Part II, question 1: a) True; b) True; c) True; d) False. a) True: 30+402=35\dfrac{30+40}{2}=35. b) True: xˉ=60+150+280+9020=29\bar{x}=\dfrac{60+150+280+90}{20}=29. c) True: ∑nixi2n=1850020=925\dfrac{\sum n_ix_i^2}{n}=\dfrac{18500}{20}=925 and s2=925−292=84s^2=925-29^2=84. d) False: every deviation is multiplied by 22, so the variance is multiplied by 44 and becomes 336336.
  6. Part III, question 1: 2.65. The class midpoints are 1.51.5, 4.54.5, 7.57.5, 10.510.5. xˉ=18330=6.1\bar{x}=\dfrac{183}{30}=6.1 and ∑nixi2n=1327.530=44.25\dfrac{\sum n_ix_i^2}{n}=\dfrac{1327.5}{30}=44.25, so s2=44.25−6.12=7.04s^2=44.25-6.1^2=7.04 and s≈2.653s\approx2.653, which rounds to 2.652.65.
  7. Part III, question 2: 0.65. The table is symmetric, so xˉ=50\bar{x}=50; the deviations are −1.5-1.5, −0.5-0.5, 0.50.5, 1.51.5. s2=2(4⋅2.25+16⋅0.25)40=2640=0.65s^2=\dfrac{2\left(4\cdot2.25+16\cdot0.25\right)}{40}=\dfrac{26}{40}=0.65.