TExcelTAD
Home › School Probability & Statistics on Paper › Calculating Mean and Variance for Grouped Data

Calculating Mean and Variance for Grouped Data

In large-scale surveys, scientific experiments, or census reports, raw individual observations are frequently consolidated into grouped frequency tables (such as age brackets 20−29,30−39…20-29, 30-39\dots, or score ranges).

Once data is grouped into intervals, individual raw numbers are lost. We no longer know the exact values within each class—only how many observations fell inside that interval. To calculate the mean, variance, and standard deviation on paper, statisticians adopt a fundamental modeling assumption: all observations in a class are represented by the class midpoint.


The Midpoint Approximation Principle

Given Class Interval [a,b):Class Midpoint: xi=a+b2Modeling Assumption:Every one of the fi observations in class i has value xi.\begin{aligned} \text{Given Class Interval } [a, b): \quad &\text{Class Midpoint: } x_i = \frac{a + b}{2} \\ \text{Modeling Assumption:} \quad &\text{Every one of the } f_i \text{ observations in class } i \text{ has value } x_i. \end{aligned}

Because actual data points are distributed throughout the interval rather than concentrated exactly at the center, all grouped measures are estimates. As long as intervals are reasonably narrow and symmetric, this approximation is remarkably accurate.


Formula Box: Grouped Summary Statistics

Let kk be the number of classes, xix_i the midpoint of class ii, and fif_i the frequency of class ii.

Total Sample Size (n):n=∑i=1kfiEstimated Mean (xˉ):xˉ=∑i=1kfixin=∑fixi∑fiEstimated Sample Variance (s2):s2=1n−1(∑i=1kfixi2−(∑fixi)2n)Estimated Standard Deviation (s):s=s2\begin{aligned} \text{Total Sample Size } (n): \quad &n = \sum_{i=1}^k f_i \\ \text{Estimated Mean } (\bar{x}): \quad &\bar{x} = \frac{\sum_{i=1}^k f_i x_i}{n} = \frac{\sum f_i x_i}{\sum f_i} \\ \text{Estimated Sample Variance } (s^2): \quad &s^2 = \frac{1}{n - 1} \left( \sum_{i=1}^k f_i x_i^2 - \frac{(\sum f_i x_i)^2}{n} \right) \\ \text{Estimated Standard Deviation } (s): \quad &s = \sqrt{s^2} \end{aligned}

Median by Linear Interpolation (School Paper Formula)

To estimate the median value x~\tilde{x} within the median class:

x~=L+(n2−cfprevfm)⋅w\tilde{x} = L + \left( \frac{\frac{n}{2} - cf_{\text{prev}}}{f_m} \right) \cdot w

where:

  • LL = lower boundary of the median class
  • nn = total frequency (∑fi\sum f_i)
  • cfprevcf_{\text{prev}} = cumulative frequency of the class immediately before the median class
  • fmf_m = frequency of the median class itself
  • ww = width of the median class

Step-by-Step Paper Notebook Method

To calculate grouped statistics cleanly without messy scratch paper, lay out a structured 55-column paper table:

Col 1: Class Interval Col 2: Midpoint (xix_i) Col 3: Frequency (fif_i) Col 4: fixif_i x_i Col 5: fixi2f_i x_i^2

Step-by-Step Execution:

  1. Fill Columns 1, 2, and 3: Compute each midpoint xi=a+b2x_i = \frac{a+b}{2} and write the given frequencies fif_i.
  2. Compute Column 4 (fixif_i x_i): Multiply Col 2 by Col 3.
  3. Compute Column 5 (fixi2f_i x_i^2): Use the paper multiplication trick:
    fixi2=(fixi)×xi=(Col 4)×(Col 2)f_i x_i^2 = (f_i x_i) \times x_i = (\text{Col 4}) \times (\text{Col 2})
    (Multiplying Col 4 by Col 2 is far faster and less error-prone than squaring xix_i first and then multiplying by fif_i!)
  4. Sum the Key Columns:
    • Sum Col 3 to get n=∑fin = \sum f_i.
    • Sum Col 4 to get ∑fixi\sum f_i x_i.
    • Sum Col 5 to get ∑fixi2\sum f_i x_i^2.
  5. Compute the Mean: xˉ=∑fixin\bar{x} = \frac{\sum f_i x_i}{n}.
  6. Compute Sample Variance (s2s^2) and Standard Deviation (ss):
    • Correction term: (∑fixi)2n\frac{(\sum f_i x_i)^2}{n}.
    • SS=∑fixi2−(∑fixi)2nSS = \sum f_i x_i^2 - \frac{(\sum f_i x_i)^2}{n}.
    • s2=SSn−1s^2 = \frac{SS}{n - 1}, then s=s2s = \sqrt{s^2}.

Worked Examples

Example 1: Full Paper Table Calculation of Mean and Standard Deviation

Problem: A school library records the duration of visits (in minutes) for a sample of 4040 students:

Duration (minutes\text{minutes}) Frequency (fif_i)
[0,10)[0, 10) 66
[10,20)[10, 20) 1414
[20,30)[20, 30) 1212
[30,40)[30, 40) 88

Calculate the estimated sample mean xˉ\bar{x}, sample variance s2s^2, and sample standard deviation ss on paper.

Step-by-Step Paper Solution:

  1. Calculate Midpoints:

    • [0,10)  ⟹  x1=0+102=5[0, 10) \implies x_1 = \frac{0+10}{2} = 5
    • [10,20)  ⟹  x2=10+202=15[10, 20) \implies x_2 = \frac{10+20}{2} = 15
    • [20,30)  ⟹  x3=20+302=25[20, 30) \implies x_3 = \frac{20+30}{2} = 25
    • [30,40)  ⟹  x4=30+402=35[30, 40) \implies x_4 = \frac{30+40}{2} = 35
  2. Construct the Calculation Table:

Class Midpoint (xix_i) fif_i fixif_i x_i fixi2=(fixi)⋅xif_i x_i^2 = (f_i x_i) \cdot x_i
[0,10)[0, 10) 55 66 6×5=306 \times 5 = 30 30×5=15030 \times 5 = 150
[10,20)[10, 20) 1515 1414 14×15=21014 \times 15 = 210 210×15=3150210 \times 15 = 3150
[20,30)[20, 30) 2525 1212 12×25=30012 \times 25 = 300 300×25=7500300 \times 25 = 7500
[30,40)[30, 40) 3535 88 8×35=2808 \times 35 = 280 280×35=9800280 \times 35 = 9800
Total — n=40n = \mathbf{40} ∑fixi=820\sum f_i x_i = \mathbf{820} ∑fixi2=20600\sum f_i x_i^2 = \mathbf{20600}
  1. Calculate the Estimated Mean (xˉ\bar{x}):

    xˉ=∑fixin=82040=824=20.5 minutes\bar{x} = \frac{\sum f_i x_i}{n} = \frac{820}{40} = \frac{82}{4} = 20.5\text{ minutes}
  2. Calculate the Correction Term:

    (∑fixi)2n=820240=67240040=16810\frac{(\sum f_i x_i)^2}{n} = \frac{820^2}{40} = \frac{672400}{40} = 16810

    (Paper shortcut check: (∑fixi)2n=(∑fixi)×xˉ=820×20.5=16810\frac{(\sum f_i x_i)^2}{n} = (\sum f_i x_i) \times \bar{x} = 820 \times 20.5 = 16810.)

  3. Calculate the Sample Variance (s2s^2):

    SS=∑fixi2−(∑fixi)2n=20600−16810=3790\begin{aligned} SS &= \sum f_i x_i^2 - \frac{(\sum f_i x_i)^2}{n} \\ &= 20600 - 16810 = 3790 \end{aligned}

    Divide by n−1=40−1=39n - 1 = 40 - 1 = 39:

    s2=379039≈97.179 minutes2s^2 = \frac{3790}{39} \approx 97.179\text{ minutes}^2
  4. Calculate the Sample Standard Deviation (ss):

    s=379039=97.179≈9.86 minutess = \sqrt{\frac{3790}{39}} = \sqrt{97.179} \approx 9.86\text{ minutes}

Example 2: Modal Class and Median by Linear Interpolation

Problem: Using the library visit data from Example 1:

  1. Identify the modal class.
  2. Estimate the median visit duration x~\tilde{x} using linear interpolation on paper.

Step-by-Step Paper Solution:

  1. Find the Modal Class:

    • Frequencies are: 6,14,12,86, 14, 12, 8.
    • The highest frequency is 1414, belonging to interval [10,20)[10, 20).
    • Modal class: [10,20) minutes[10, 20)\text{ minutes}.
  2. Locate the Median Class:

    • Sample size n=40n = 40.
    • The middle position is n2=402=20\frac{n}{2} = \frac{40}{2} = 20.
    • Cumulative frequencies:
      • Class 1 ([0,10)[0, 10)): cf1=6cf_1 = 6
      • Class 2 ([10,20)[10, 20)): cf2=6+14=20cf_2 = 6 + 14 = 20
    • Since cf2=20cf_2 = 20, the 20th20\text{th} student falls exactly at the upper boundary of class [10,20)[10, 20).
    • Median class is [10,20)[10, 20).
  3. Apply Linear Interpolation Formula:

    • Lower boundary L=10L = 10
    • n2=20\frac{n}{2} = 20
    • cfprev=cf1=6cf_{\text{prev}} = cf_1 = 6
    • fm=14f_m = 14
    • Class width w=20−10=10w = 20 - 10 = 10
    x~=L+(n2−cfprevfm)⋅w=10+(20−614)⋅10=10+(1414)⋅10=10+1⋅10=20.0 minutes\begin{aligned} \tilde{x} &= L + \left( \frac{\frac{n}{2} - cf_{\text{prev}}}{f_m} \right) \cdot w \\ &= 10 + \left( \frac{20 - 6}{14} \right) \cdot 10 \\ &= 10 + \left( \frac{14}{14} \right) \cdot 10 \\ &= 10 + 1 \cdot 10 = 20.0\text{ minutes} \end{aligned}

Final Answer:

  • Modal class: [10,20) minutes[10, 20)\text{ minutes}
  • Estimated Median: 20.0 minutes20.0\text{ minutes}

Example 3: Why Grouped Statistics Are Estimates (Grouping Error)

Problem: Consider three exact raw measurements: 11,12,1311, 12, 13.

  1. Calculate the exact sample mean and exact sample variance.
  2. Group all three measurements into a single class [10,20)[10, 20) with midpoint x1=15x_1 = 15 and frequency f1=3f_1 = 3. Calculate the grouped sample mean and grouped sample variance.
  3. Explain the discrepancy.

Step-by-Step Paper Solution:

  1. Exact Raw Calculations:

    xˉraw=11+12+133=363=12\bar{x}_{\text{raw}} = \frac{11 + 12 + 13}{3} = \frac{36}{3} = 12
    sraw2=(11−12)2+(12−12)2+(13−12)23−1=1+0+12=1s_{\text{raw}}^2 = \frac{(11 - 12)^2 + (12 - 12)^2 + (13 - 12)^2}{3 - 1} = \frac{1 + 0 + 1}{2} = 1
  2. Grouped Calculations:

    • Midpoint x1=15x_1 = 15, f1=3f_1 = 3.
    xˉgrouped=f1x1n=3×153=15\bar{x}_{\text{grouped}} = \frac{f_1 x_1}{n} = \frac{3 \times 15}{3} = 15
    • Since all three values are assigned to the midpoint 1515, every deviation (xi−xˉ)=(15−15)=0(x_i - \bar{x}) = (15 - 15) = 0.
    sgrouped2=3×(15−15)23−1=0s_{\text{grouped}}^2 = \frac{3 \times (15 - 15)^2}{3 - 1} = 0
  3. Analysis:

    • Grouping assumed the data was centered at 1515, whereas all raw values were near the lower end (11,12,1311, 12, 13).
    • This difference is called grouping error. To minimize grouping error on paper, class intervals should be kept appropriately narrow and evenly distributed.

Common Mistakes & Paper Traps

  1. The (fixi)2(f_i x_i)^2 vs fixi2f_i x_i^2 Trap:

    • The most common algebraic error in grouped statistics!
    • (fixi)2=fi2xi2(f_i x_i)^2 = f_i^2 x_i^2, which squares the frequency.
    • We require fixi2=fi×(xi2)f_i x_i^2 = f_i \times (x_i^2).
    • Safe method: Multiply your fixif_i x_i column by the xix_i column.
  2. Dividing by kk (Number of Classes) Instead of nn:

    • Writing xˉ=∑fixi4\bar{x} = \frac{\sum f_i x_i}{4} when there are 44 classes, forgetting that n=∑fi=40n = \sum f_i = 40.
    • Always divide by the total number of observations nn.
  3. Wrong Midpoint for Inclusive Paper Intervals:

    • If an interval is written as 1−5,6−101 - 5, 6 - 10 for discrete integer data, the true mathematical class limits are [0.5,5.5)[0.5, 5.5) and [5.5,10.5)[5.5, 10.5).
    • The midpoint is 1+52=3\frac{1 + 5}{2} = 3 and 6+102=8\frac{6 + 10}{2} = 8. Always compute Lower+Upper2\frac{\text{Lower} + \text{Upper}}{2}.
  4. Forgetting n−1n - 1 in Sample Variance:

    • Remember that for sample variance, the denominator is n−1n - 1, not nn.

Pencil & Paper Practice

Practice 1

A seedling nursery records the heights of 2020 tomato plants:

Height (cm\text{cm}) Frequency (fif_i)
[10,20)[10, 20) 33
[20,30)[20, 30) 88
[30,40)[30, 40) 77
[40,50)[40, 50) 22

Compute on paper:

  1. The estimated mean height xˉ\bar{x}.
  2. The estimated sample variance s2s^2 and standard deviation ss.

Practice 2

Using the table from Practice 1:

  1. State the modal class.
  2. Estimate the median height using linear interpolation.

Worked Solutions for Practice Problems

Solution to Practice 1

  1. Midpoints: 15,25,35,4515, 25, 35, 45.
  2. Calculation Table:
Interval Midpoint (xix_i) fif_i fixif_i x_i fixi2f_i x_i^2
[10,20)[10, 20) 1515 33 4545 45×15=67545 \times 15 = 675
[20,30)[20, 30) 2525 88 200200 200×25=5000200 \times 25 = 5000
[30,40)[30, 40) 3535 77 245245 245×35=8575245 \times 35 = 8575
[40,50)[40, 50) 4545 22 9090 90×45=405090 \times 45 = 4050
Total — n=20n = 20 ∑fixi=580\sum f_i x_i = 580 ∑fixi2=18300\sum f_i x_i^2 = 18300
  1. Mean:
    xˉ=58020=29.0 cm\bar{x} = \frac{580}{20} = 29.0\text{ cm}
  2. Correction Term and Variance:
    (∑fixi)2n=580220=33640020=16820\frac{(\sum f_i x_i)^2}{n} = \frac{580^2}{20} = \frac{336400}{20} = 16820
    SS=18300−16820=1480SS = 18300 - 16820 = 1480
    s2=148020−1=148019≈77.89 cm2s^2 = \frac{1480}{20 - 1} = \frac{1480}{19} \approx 77.89\text{ cm}^2
    s=148019≈8.83 cms = \sqrt{\frac{1480}{19}} \approx 8.83\text{ cm}

Solution to Practice 2

  1. Modal Class: The highest frequency is 88, in class [20,30) cm[20, 30)\text{ cm}.
  2. Median Interpolation:
    • n2=10\frac{n}{2} = 10.
    • Cumulative frequencies: cf1=3cf_1 = 3, cf2=3+8=11cf_2 = 3 + 8 = 11.
    • Median falls in class [20,30)[20, 30) (L=20,w=10,cfprev=3,fm=8L = 20, w = 10, cf_{\text{prev}} = 3, f_m = 8).
    x~=20+(10−38)⋅10=20+(78)⋅10=20+8.75=28.75 cm\tilde{x} = 20 + \left( \frac{10 - 3}{8} \right) \cdot 10 = 20 + \left( \frac{7}{8} \right) \cdot 10 = 20 + 8.75 = 28.75\text{ cm}

Test yourself

In a grouped frequency table, why do we use class midpoints xix_i to calculate the mean?

  1. Because the midpoint is always the exact average of every class
  2. Because individual raw data values within intervals are unknown, and midpoints serve as representative values
  3. Because midpoints eliminate the need to know the frequencies
  4. Because standard deviation is only defined for integer midpoints

For a class interval with midpoint xi=20x_i = 20 and frequency fi=4f_i = 4, what is the value of fixi2f_i x_i^2?

  1. 16001600
  2. 8080
  3. 64006400
  4. 320320

A grouped dataset of n=50n = 50 items has ∑fixi=1500\sum f_i x_i = 1500 and ∑fixi2=46250\sum f_i x_i^2 = 46250. What is the sample variance s2s^2?

  1. 25.025.0
  2. 25.5125.51
  3. 12501250
  4. 30.030.0