Statistics · Lesson 4 of 6
Grouped Variance and Shortcut Calculations
“Calculate spread from class intervals and connect direct, second-moment and coded methods.”
• Use class midpoints and frequencies to estimate grouped variance and standard deviation. • Derive the second-moment identity from squared deviations about the mean. • Choose between direct deviations, original-value squares and step-deviation calculations. • Derive how assumed-mean coding changes the mean, variance and standard deviation. • Convert inclusive classes to continuous boundaries and retain precision through calculations.
The same definition, represented by class midpoints
For continuous grouped data the exact observations have been replaced by intervals and their frequencies. Represent each interval by its midpoint xᵢ, calculate the weighted mean, and average the weighted squared deviations from that mean. The method is the same as for a discrete frequency distribution, with the important qualification that midpoint representation approximates the original data.
The grouped mean, variance and standard deviation describe the midpoint model. They are useful summaries when raw values are unavailable, but they are not guaranteed to equal the corresponding statistics of those hidden raw values. As before, total frequency N counts the observations, not the classes. The class limits determine the midpoints and need to be interpreted consistently.
Problem
Classes 30–40, 40–50, 50–60, 60–70, 70–80, 80–90, 90–100 have frequencies 3, 7, 12, 15, 8, 3, 2. Find the mean, variance and standard deviation.
- 1.Midpoints are 35, 45, 55, 65, 75, 85 and 95. Total frequency is 50 and the weighted midpoint sum is 3100.
- 2.The mean is 3100/50 = 62.
- 3.Deviations from 62 are −27, −17, −7, 3, 13, 23 and 33. Their squares are 729, 289, 49, 9, 169, 529 and 1089.
- 4.Multiplying by frequencies gives 2187, 2023, 588, 135, 1352, 1587 and 2178, whose sum is 10050.
- 5.Variance is 10050/50 = 201. Standard deviation is √201 ≈ 14.18, in the same unit as the observations.
| Class | Frequency | Midpoint | fᵢxᵢ | (xᵢ − 62)² | fᵢ(xᵢ − 62)² |
|---|---|---|---|---|---|
| 30–40 | 3 | 35 | 105 | 729 | 2187 |
| 40–50 | 7 | 45 | 315 | 289 | 2023 |
| 50–60 | 12 | 55 | 660 | 49 | 588 |
| 60–70 | 15 | 65 | 975 | 9 | 135 |
| 70–80 | 8 | 75 | 600 | 169 | 1352 |
| 80–90 | 3 | 85 | 255 | 529 | 1587 |
| 90–100 | 2 | 95 | 190 | 1089 | 2178 |
| Total | 50 | 3100 | 10050 |
Derive a formula using original-value squares
A direct-deviation table works well when the mean is simple. When it is a fraction, repeated subtraction and squaring can be awkward. Expanding the variance definition produces an equivalent identity based on the weighted sum of values and the weighted sum of their squares. We derive it so that it is clear why it works and why the mean must be squared.
Expand (xᵢ − x̄)² as xᵢ² − 2xᵢx̄ + x̄², multiply by fᵢ, and add. The mean x̄ is fixed across rows, so it can be taken outside the sum. Thus the squared-deviation total is Σfᵢxᵢ² − 2x̄Σfᵢxᵢ + x̄²Σfᵢ. Since Σfᵢxᵢ = Nx̄ and Σfᵢ = N, this simplifies to Σfᵢxᵢ² − Nx̄². Divide by N to obtain the identity.
For raw ungrouped data, treat every frequency as 1 and use N = n. This gives σ² = Σxᵢ²/n − (Σxᵢ/n)². The identity is also useful when totals rather than a full list are available, and later when a mistaken observation needs to be corrected.
Problem
Values 3, 8, 13, 18, 23 have frequencies 7, 10, 15, 10, 6. Find standard deviation.
- 1.A table gives N = 48, Σfᵢxᵢ = 614 and Σfᵢxᵢ² = 9652.
- 2.The exact mean is 614/48 = 307/24. Keep this fraction rather than rounding it before subtracting squares.
- 3.Variance = 9652/48 − (614/48)² = (48 × 9652 − 614²)/48².
- 4.The numerator is 463296 − 376996 = 86300. Thus variance = 86300/2304 = 21575/576 ≈ 37.4566.
- 5.Standard deviation = √86300/48 ≈ 6.12. This agrees with a full deviation calculation but avoids repeated fractional subtractions.
| Value xᵢ | Frequency fᵢ | fᵢxᵢ | xᵢ² | fᵢxᵢ² |
|---|---|---|---|---|
| 3 | 7 | 21 | 9 | 63 |
| 8 | 10 | 80 | 64 | 640 |
| 13 | 15 | 195 | 169 | 2535 |
| 18 | 10 | 180 | 324 | 3240 |
| 23 | 6 | 138 | 529 | 3174 |
| Total | 48 | 614 | 9652 |
fᵢxᵢ² means fᵢ × (xᵢ)², not (fᵢxᵢ)². Also Σfᵢxᵢ² and (Σfᵢxᵢ)² are different quantities. Check the placement of brackets before using the identity.
Coding connects easier numbers to the original data
Earlier, we found a mean by subtracting a convenient reference and dividing by a common scale. The same coding can simplify variance. Choose assumed mean A and positive scale h, and set yᵢ = (xᵢ − A)/h. Then xᵢ = A + hyᵢ. We calculate in y, but our final answer must describe x.
Let ȳ = Σfᵢyᵢ/N. Substituting xᵢ = A + hyᵢ in the weighted mean shows x̄ = A + hȳ. Now subtract means: xᵢ − x̄ = A + hyᵢ − A − hȳ = h(yᵢ − ȳ). The assumed origin A cancels, while the scale factor h remains.
Squaring gives (xᵢ − x̄)² = h²(yᵢ − ȳ)². Weight and average to obtain σₓ² = h²σᵧ². Taking the nonnegative square root gives σₓ = hσᵧ because h was chosen positive. This explains why changing the origin does not alter spread, but changing the scale does.
Use the second-moment identity on the coded values to calculate σᵧ², then multiply by h². This combines two earlier ideas into a shortcut rather than creating a new measure. Integer codes such as −3 to 3 are often easier to multiply and square than original midpoints such as 35 to 95.
Problem
Recalculate the distribution with classes 30–40 through 90–100 using A = 65 and h = 10.
- 1.Codes for midpoints 35, 45, 55, 65, 75, 85, 95 are −3, −2, −1, 0, 1, 2, 3.
- 2.The coding table gives N = 50, Σfᵢyᵢ = −15 and Σfᵢyᵢ² = 105.
- 3.Mean = 65 + 10(−15/50) = 62.
- 4.Variance = 100[105/50 − (−15/50)²] = 100(2.1 − 0.09) = 201.
- 5.Standard deviation is √201 ≈ 14.18. The shortcut and direct method give exactly the same midpoint-model results.
| Class | Frequency | Midpoint | yᵢ | yᵢ² | fᵢyᵢ | fᵢyᵢ² |
|---|---|---|---|---|---|---|
| 30–40 | 3 | 35 | -3 | 9 | -9 | 27 |
| 40–50 | 7 | 45 | -2 | 4 | -14 | 28 |
| 50–60 | 12 | 55 | -1 | 1 | -12 | 12 |
| 60–70 | 15 | 65 | 0 | 0 | 0 | 0 |
| 70–80 | 8 | 75 | 1 | 1 | 8 | 8 |
| 80–90 | 3 | 85 | 2 | 4 | 6 | 12 |
| 90–100 | 2 | 95 | 3 | 9 | 6 | 18 |
| Total | 50 | -15 | 105 |
Problem
Use A = 13 and h = 5 for values 3, 8, 13, 18, 23 with frequencies 7, 10, 15, 10, 6.
- 1.The codes are −2, −1, 0, 1, 2. Weighted code sum is −14 − 10 + 0 + 10 + 12 = −2.
- 2.Weighted squared-code sum is 28 + 10 + 0 + 10 + 24 = 72; N = 48.
- 3.The mean is 13 + 5(−2/48) = 307/24, agreeing with 614/48.
- 4.Variance = 25[72/48 − (−2/48)²] = 25[3/2 − 1/576] = 21575/576.
- 5.Its nonnegative square root is approximately 6.12. Coding works for this exact discrete distribution as well as for class midpoints.
Inclusive diameter classes need continuous boundaries
Measurements recorded to the nearest millimetre may be grouped as 33–36, 37–40 and so on. Convert them to adjacent boundaries before applying grouped methods. Their class widths are then 4 mm, and their midpoints are 34.5, 38.5 and so on. A central midpoint and the common width make convenient coding choices.
Problem
Diameter classes 33–36, 37–40, 41–44, 45–48, 49–52 mm have frequencies 15, 17, 21, 22, 25. Find the mean diameter and standard deviation.
- 1.Convert boundaries to 32.5–36.5, 36.5–40.5, 40.5–44.5, 44.5–48.5 and 48.5–52.5. Midpoints are 34.5, 38.5, 42.5, 46.5, 50.5.
- 2.Choose A = 42.5 mm and h = 4 mm. Codes are −2, −1, 0, 1, 2, with N = 100.
- 3.Weighted code sum is −30 − 17 + 0 + 22 + 50 = 25. Weighted squared-code sum is 60 + 17 + 0 + 22 + 100 = 199.
- 4.Mean = 42.5 + 4 × 25/100 = 43.5 mm.
- 5.Variance = 16[199/100 − (25/100)²] = 16(1.99 − 0.0625) = 30.84 mm².
- 6.Standard deviation is √30.84 ≈ 5.55 mm. These are grouped estimates based on midpoint representation.
| Continuous class (mm) | Frequency | Midpoint (mm) | Code yᵢ | fᵢyᵢ | fᵢyᵢ² |
|---|---|---|---|---|---|
| 32.5–36.5 | 15 | 34.5 | -2 | -30 | 60 |
| 36.5–40.5 | 17 | 38.5 | -1 | -17 | 17 |
| 40.5–44.5 | 21 | 42.5 | 0 | 0 | 0 |
| 44.5–48.5 | 22 | 46.5 | 1 | 22 | 22 |
| 48.5–52.5 | 25 | 50.5 | 2 | 50 | 100 |
| Total | 100 | 25 | 199 |
Choose the calculation that makes errors least likely
Direct deviations make the meaning of variance visible and work well with a simple mean. Original-value squares avoid repeated fractional deviations. Coding is useful when values are large but regularly spaced. Whichever method you choose, the definitions and the final unit stay the same; a shortcut changes the arithmetic rather than the statistic.
Keep exact fractions or sufficient decimal precision until the end. The second-moment method subtracts two potentially large numbers, so prematurely rounded totals or means can distort the smaller difference. An apparently negative variance indicates an arithmetic, rounding or data error, because an average of squares cannot be negative. Recheck the totals instead of reporting a negative spread.
After calculating variance of y, multiply by h² to report variance of x. After calculating standard deviation of y, multiply by h. Adding A back is needed for the mean, but not for variance or standard deviation.
Check your understanding
These questions connect the equivalent formulas and the effects of coding. Pay attention to whether a number is a squared total, a mean, a coded variance or a value already restored to the original scale.
Quiz
Which expression gives variance from original-value totals?
If yᵢ = (xᵢ − 65)/10 and variance of y is 2.01, what is variance of x?
For the same coding, if standard deviation of y is 1.5, what is standard deviation of x?
With A = 65, h = 10, N = 50 and Σfᵢyᵢ = −15, what is the mean of x?
What is the midpoint of continuous class 32.5–36.5?
What does fᵢxᵢ² mean?
A grouped variance calculation gives a negative number. What is the appropriate conclusion?
Practice Problems
- Derive σ² = Σfᵢxᵢ²/N − x̄² from the weighted squared-deviation definition, showing where Σfᵢxᵢ = Nx̄ is used.
- Values 60 through 68 have frequencies 2, 1, 12, 29, 25, 12, 10, 4, 5. Find mean and standard deviation using a convenient coding.
- Classes 0–30 through 180–210 have frequencies 2, 3, 5, 10, 3, 5, 2. Calculate the mean and variance.
- Classes 0–10 through 40–50 have frequencies 5, 8, 15, 16, 6. Compare direct and step-deviation variance calculations.
- Height classes 70–75 through 110–115 cm have frequencies 3, 4, 7, 7, 15, 9, 6, 6, 3. Find mean, variance and standard deviation by coding.
- For the diameter distribution above, verify the mean and variance using original midpoint totals instead of coding.
- Explain why subtracting an assumed mean does not change spread but changing the scale does.
- Explain why a grouped midpoint estimate need not equal the statistic calculated from the original raw observations.
Key Takeaways
• Continuous grouped calculations apply frequency formulas to class midpoints and are estimates of raw-data statistics. • Variance equals the average of squared values minus the square of the mean. • Step-deviation coding gives x̄ = A + hȳ, σₓ² = h²σᵧ² and σₓ = hσᵧ for positive h. • Use continuous boundaries and a consistent class width where inclusive classes need adjustment. • Choose a direct, second-moment or coded calculation to suit the data, and preserve precision until the final result. • A negative variance or a forgotten scale factor signals a calculation that needs checking.