Skip to lesson content

Lesson 4 of 6

Statistics · Lesson 4 of 6

Grouped Variance and Shortcut Calculations

“Calculate spread from class intervals and connect direct, second-moment and coded methods.”

Learning Objectives

• 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.

Grouped variance from midpoint deviationsLaTeX
Here xᵢ denotes the midpoint of class i, fᵢ its frequency and N = Σfᵢ. The same formula applies to exact discrete values when xᵢ is an observed value.
Example — A continuous distribution by direct deviations

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. 1.Midpoints are 35, 45, 55, 65, 75, 85 and 95. Total frequency is 50 and the weighted midpoint sum is 3100.
  2. 2.The mean is 3100/50 = 62.
  3. 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. 4.Multiplying by frequencies gives 2187, 2023, 588, 135, 1352, 1587 and 2178, whose sum is 10050.
  5. 5.Variance is 10050/50 = 201. Standard deviation is √201 ≈ 14.18, in the same unit as the observations.
ClassFrequencyMidpointfᵢxᵢ(xᵢ − 62)²fᵢ(xᵢ − 62)²
30–403351057292187
40–507453152892023
50–60125566049588
60–7015659759135
70–808756001691352
80–903852555291587
90–10029519010892178
Total50310010050

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.

Second-moment variance identityLaTeX
The average of squared values is sometimes called the second moment about zero. Variance is this quantity minus the square of the mean, not minus the mean itself.

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.

Equivalent standard deviation expressionLaTeX
Because N > 0, the factor 1/N can be taken outside the square root. The entire difference is under that square root.
Example — A discrete table using the second-moment identity

Problem
Values 3, 8, 13, 18, 23 have frequencies 7, 10, 15, 10, 6. Find standard deviation.

  1. 1.A table gives N = 48, Σfᵢxᵢ = 614 and Σfᵢxᵢ² = 9652.
  2. 2.The exact mean is 614/48 = 307/24. Keep this fraction rather than rounding it before subtracting squares.
  3. 3.Variance = 9652/48 − (614/48)² = (48 × 9652 − 614²)/48².
  4. 4.The numerator is 463296 − 376996 = 86300. Thus variance = 86300/2304 = 21575/576 ≈ 37.4566.
  5. 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ᵢ²
3721963
8108064640
13151951692535
18101803243240
2361385293174
Total486149652
Keep the square attached to each value before weighting

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.

Mean, variance and standard deviation under codingLaTeX
A changes the reference point, while h rescales distances. Variance must be restored using h²; standard deviation uses h.

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.

Step-deviation variance and standard deviationLaTeX
yᵢ = (xᵢ − A)/h. This form displays the average coded square and the squared coded mean separately.
Example — The continuous distribution by shortcut

Problem
Recalculate the distribution with classes 30–40 through 90–100 using A = 65 and h = 10.

  1. 1.Codes for midpoints 35, 45, 55, 65, 75, 85, 95 are −3, −2, −1, 0, 1, 2, 3.
  2. 2.The coding table gives N = 50, Σfᵢyᵢ = −15 and Σfᵢyᵢ² = 105.
  3. 3.Mean = 65 + 10(−15/50) = 62.
  4. 4.Variance = 100[105/50 − (−15/50)²] = 100(2.1 − 0.09) = 201.
  5. 5.Standard deviation is √201 ≈ 14.18. The shortcut and direct method give exactly the same midpoint-model results.
ClassFrequencyMidpointyᵢyᵢ²fᵢyᵢfᵢyᵢ²
30–40335-39-927
40–50745-24-1428
50–601255-11-1212
60–7015650000
70–808751188
80–9038524612
90–10029539618
Total50-15105
Example — A discrete table can use coding too

Problem
Use A = 13 and h = 5 for values 3, 8, 13, 18, 23 with frequencies 7, 10, 15, 10, 6.

  1. 1.The codes are −2, −1, 0, 1, 2. Weighted code sum is −14 − 10 + 0 + 10 + 12 = −2.
  2. 2.Weighted squared-code sum is 28 + 10 + 0 + 10 + 24 = 72; N = 48.
  3. 3.The mean is 13 + 5(−2/48) = 307/24, agreeing with 614/48.
  4. 4.Variance = 25[72/48 − (−2/48)²] = 25[3/2 − 1/576] = 21575/576.
  5. 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.

Example — Mean and spread of grouped diameters

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. 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. 2.Choose A = 42.5 mm and h = 4 mm. Codes are −2, −1, 0, 1, 2, with N = 100.
  3. 3.Weighted code sum is −30 − 17 + 0 + 22 + 50 = 25. Weighted squared-code sum is 60 + 17 + 0 + 22 + 100 = 199.
  4. 4.Mean = 42.5 + 4 × 25/100 = 43.5 mm.
  5. 5.Variance = 16[199/100 − (25/100)²] = 16(1.99 − 0.0625) = 30.84 mm².
  6. 6.Standard deviation is √30.84 ≈ 5.55 mm. These are grouped estimates based on midpoint representation.
Continuous class (mm)FrequencyMidpoint (mm)Code yᵢfᵢyᵢfᵢyᵢ²
32.5–36.51534.5-2-3060
36.5–40.51738.5-1-1717
40.5–44.52142.5000
44.5–48.52246.512222
48.5–52.52550.5250100
Total10025199

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.

A coded result is not yet in the original unit

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

Quick check

Which expression gives variance from original-value totals?

Quick check

If yᵢ = (xᵢ − 65)/10 and variance of y is 2.01, what is variance of x?

Quick check

For the same coding, if standard deviation of y is 1.5, what is standard deviation of x?

Quick check

With A = 65, h = 10, N = 50 and Σfᵢyᵢ = −15, what is the mean of x?

Quick check

What is the midpoint of continuous class 32.5–36.5?

Quick check

What does fᵢxᵢ² mean?

Quick check

A grouped variance calculation gives a negative number. What is the appropriate conclusion?

Practice Problems

Practice Problems
  1. Derive σ² = Σfᵢxᵢ²/N − x̄² from the weighted squared-deviation definition, showing where Σfᵢxᵢ = Nx̄ is used.
  2. Values 60 through 68 have frequencies 2, 1, 12, 29, 25, 12, 10, 4, 5. Find mean and standard deviation using a convenient coding.
  3. Classes 0–30 through 180–210 have frequencies 2, 3, 5, 10, 3, 5, 2. Calculate the mean and variance.
  4. Classes 0–10 through 40–50 have frequencies 5, 8, 15, 16, 6. Compare direct and step-deviation variance calculations.
  5. 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.
  6. For the diameter distribution above, verify the mean and variance using original midpoint totals instead of coding.
  7. Explain why subtracting an assumed mean does not change spread but changing the scale does.
  8. Explain why a grouped midpoint estimate need not equal the statistic calculated from the original raw observations.

Key Takeaways

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.