Grouped data formulas
| Statistic | Formula |
|---|---|
| Mean | x̄ = Σf·m ÷ n |
| Median | L + ((n/2 − CF) ÷ f) × w |
| Mode | L + ((f₁ − f₀) ÷ (2f₁ − f₀ − f₂)) × w |
| Variance (sample) | s² = Σf(m − x̄)² ÷ (n − 1) |
| Quartiles | Like the median, with n/4 (Q1) and 3n/4 (Q3) |
m = class midpoint, f = frequency, n = total frequency, L = lower class boundary, CF = cumulative frequency before the class, w = class width.
Worked example: weekly wages
Wages of 70 workers: 200–300: 6, 300–400: 14, 400–500: 22, 500–600: 18, 600–700: 7, 700–800: 3.
- Mean: Σf·m = 6(250) + 14(350) + 22(450) + 18(550) + 7(650) + 3(750) = 33,000, and 33,000 ÷ 70 ≈ 471.43.
- Median: n/2 = 35. Cumulative frequencies are 6, 20, 42…, so the median class is 400–500 with CF = 20 and f = 22. Median = 400 + ((35 − 20) ÷ 22) × 100 ≈ 468.18.
- Mode: the modal class is 400–500 (f₁ = 22, f₀ = 14, f₂ = 18). Mode = 400 + (8 ÷ 12) × 100 ≈ 466.67.
This is the default example above, so you can check each step.
Class limits like 10–19, 20–29
When classes are written with gaps between them, the median and mode formulas need the class boundaries (9.5, 19.5, 29.5…), not the limits. The calculator converts them automatically and tells you when it has. Want to see the table? Draw it with the grouped frequency histogram maker, or build a table from raw data with the frequency table maker.
Common mistakes to avoid
- Using class limits in the median formula. L is the lower class boundary (e.g. 39.5 for 40–49), not the limit.
- Using the wrong cumulative frequency. CF is the total of all classes before the median class, not including it.
- Forgetting the class width. Multiply by w at the end of the median and mode formulas.
- Treating estimates as exact. Grouped results are approximations. Say “estimated mean”.
Do it in other software
| Software | How |
|---|---|
| Excel | Midpoints in column C and frequencies in D: mean =SUMPRODUCT(C2:C7, D2:D7)/SUM(D2:D7). |
| TI-84 | Midpoints in L1, frequencies in L2, then 1-Var Stats L1, L2 for the mean and standard deviation. |
| Python | np.average(midpoints, weights=freqs) for the mean. |
Related tools: Histogram from a Frequency Table, Frequency Distribution Table Maker, Class Width Calculator, Ogive Maker and Descriptive Statistics Calculator.