A tally, not a list
A teacher marks 30 exam papers and tallies the results into classes before she files the papers away: 3 marks in 0-10, 7 in 10-20, 12 in 20-30, 6 in 30-40, 2 in 40-50. A week later she wants the variance, to say how spread out the class was. The papers are filed. The tally sheet is all she has. She knows how many marks fell in each class, and nothing about where inside a class any single mark sat.
That is grouped data. The raw numbers are gone, and only the counts per class remain. Variance needs every value's distance from the mean, so a tally looks like too little information. It is enough, with one honest approximation: pretend every value in a class sits at the middle of that class. The middle is the midpoint, and the whole method hangs on it.
The midpoint idea
The midpoint of a class is the average of its two limits. For 0-10 it is 5, for 10-20 it is 15, for 20-30 it is 25, and so on. Each class is then replaced by its midpoint, repeated as many times as the class frequency says. The 12 marks in 20-30 become twelve 25s. The table of classes turns back into a list of numbers, and the ordinary variance calculation runs on that list.
Two conventions keep the table honest. First, a class like 10-20 holds marks from 10 up to but not including 20, so a mark of exactly 20 goes in the next class up. Second, the method assumes the values spread fairly evenly inside each class. That is why the midpoint is a fair stand-in. It is also why the answer is an estimate: the real marks sat somewhere around the midpoint, not on it, and the table cannot say where. Narrower classes make the estimate better, because a value can only sit a short way from its midpoint. Classes of width 10 are the usual compromise in textbook tables. Equal widths are the usual case, and the method still works when widths differ, since every class has its own midpoint, but the table is tidier when they match.
The formula, in four steps
Call the midpoints x and the frequencies f. The total count is N, the sum of the frequencies.
Step one: the mean. Multiply each midpoint by its frequency, add, and divide by N: x̄ = Σfx ÷ N.
Step two: the squared distances. For each class, take the midpoint minus the mean, square it, and multiply by the class frequency.
Step three: add those up. That sum is the sum of squares, SS = Σf(x − x̄)².
Step four: divide. A population divides by N. A sample divides by N − 1. The square root is the standard deviation.
The frequency does the weighting. A class with 12 marks contributes twelve squared distances; a class with 2 contributes two. That is the whole difference between the grouped formula and the raw-data one: the f in front of every term.
The table method, worked by hand
Back to the teacher's tally. The classes are 0-10, 10-20, 20-30, 30-40 and 40-50, with frequencies 3, 7, 12, 6 and 2. The midpoints are 5, 15, 25, 35 and 45.
First the mean. Multiply and add: 3 × 5 is 15, 7 × 15 is 105, 12 × 25 is 300, 6 × 35 is 210, 2 × 45 is 90. The total is 720. Divide by 30 marks and the mean is 24.
Now the distances from 24. The midpoints sit at −19, −9, 1, 11 and 21 from the mean. Square them: 361, 81, 1, 121 and 441. Weight each by its frequency: 3 × 361 is 1083, 7 × 81 is 567, 12 × 1 is 12, 6 × 121 is 726, 2 × 441 is 882. Add them and the sum of squares is 3270.
Divide. The 30 students are a sample of a larger cohort, so the sample variance is 3270 ÷ 29 = 112.76, and the standard deviation is √112.76 = 10.62 marks. If the class were the whole population, the variance would be 3270 ÷ 30 = 109, with a standard deviation of 10.44.
Read the answer against the tally. A standard deviation of about 10.6 marks around a mean of 24 fits a table where most marks sit in 20-30 and the tails thin out toward 0 and 50. The number says the class was spread out, not bunched: two students a full 20 marks apart is ordinary here.
The shortcut formula
The deviation table is the honest way to learn the method, and the slow way to run it. The shortcut skips the deviations: SS = Σfx² − (Σfx)² ÷ N. Square each midpoint first, weight by frequency, add, then subtract the correction term.
The same numbers check it. Σfx² is 3 × 25 + 7 × 225 + 12 × 625 + 6 × 1225 + 2 × 2025, which is 75 + 1575 + 7500 + 7350 + 4050 = 20550. The correction term is 720² ÷ 30 = 518400 ÷ 30 = 17280. Subtract: 20550 − 17280 = 3270, the same sum of squares as the long way. Divide by 29 and the sample variance is 112.76 again.
Use the shortcut for long tables. Use the deviation table when you are learning, or when a number looks wrong and you want to see where it came from. The shortcut hides the meaning; the table shows it.
When there are no classes at all
Some frequency tables list single values instead of ranges: calls per hour, children per family, goals per match. The values are their own midpoints, so nothing is approximated and the answer is exact.
A call centre logs calls per hour over 40 hours: 0 calls in 4 hours, 1 in 9, 2 in 12, 3 in 8, 4 in 5 and 5 in 2. The mean is (0 × 4 + 1 × 9 + 2 × 12 + 3 × 8 + 4 × 5 + 5 × 2) ÷ 40 = 87 ÷ 40 = 2.175 calls an hour.
The distances from 2.175 are −2.175, −1.175, −0.175, 0.825, 1.825 and 2.825. Square them: 4.7306, 1.3806, 0.0306, 0.6806, 3.3306 and 7.9806. Weight by frequency: 4 × 4.7306 is 18.9225, 9 × 1.3806 is 12.4256, 12 × 0.0306 is 0.3675, 8 × 0.6806 is 5.4450, 5 × 3.3306 is 16.6531, 2 × 7.9806 is 15.9613. The sum of squares is 69.775. The sample variance is 69.775 ÷ 39 = 1.79, and the standard deviation is 1.34 calls. As a population the variance would be 69.775 ÷ 40 = 1.74. The frequency table calculator builds tables like this one from raw data.
How close is the grouped answer?
Grouping hides detail, so ask how much it costs. Take ten numbers whose exact variance is easy to find: 12, 14, 15, 18, 19, 21, 22, 24, 26 and 29. Their mean is 20 and their squared distances add to 268, so the exact sample variance is 268 ÷ 9 = 29.78, with a standard deviation of 5.46.
Now group them into 10-15, 15-20, 20-25 and 25-30. The frequencies are 2, 3, 3 and 2, the midpoints 12.5, 17.5, 22.5 and 27.5. The grouped mean is still 20. The grouped sum of squares is 2 × 56.25 + 3 × 6.25 + 3 × 6.25 + 2 × 56.25 = 112.5 + 18.75 + 18.75 + 112.5 = 262.5. The grouped sample variance is 262.5 ÷ 9 = 29.17, with a standard deviation of 5.40.
The grouped answer is 0.61 low on the variance, about 2%. The midpoints pulled the extremes toward the centres: 12 and 14 both became 12.5, 26 and 29 both became 27.5, and the spread shrank a little. That is the usual direction. Grouping smooths the data, so a grouped variance usually comes out a touch low. Narrower classes shrink the gap; wider classes widen it. When the raw numbers still exist, use them. The grouped method is for the tally sheet after the papers are filed.
The same calculation in a spreadsheet
Put the midpoints in A2:A6 and the frequencies in B2:B6, using the exam marks table. The mean is =SUMPRODUCT(A2:A6, B2:B6) / SUM(B2:B6), which returns 24. The sample variance is =SUMPRODUCT(B2:B6, (A2:A6 - 24)^2) / (SUM(B2:B6) - 1), which returns 112.76. For the population variance, drop the minus 1: divide by SUM(B2:B6) instead, which returns 109.
Keep the mean in its own cell and point at it instead of typing 24 into the formula, so the sheet stays correct when the data change. With the mean in C1, the sample variance is =SUMPRODUCT(B2:B6, (A2:A6 - $C$1)^2) / (SUM(B2:B6) - 1). The shortcut check is =SUMPRODUCT(B2:B6, A2:A6^2) - SUMPRODUCT(A2:A6, B2:B6)^2 / SUM(B2:B6), which returns 3270, the same sum of squares as the hand table. Run the hand table first, then let the sheet take over for the long lists.
Sample or population: which divisor?
The grouped table does not change the rule. The 30 exam marks are a sample of a larger cohort, so they divide by 29 and give 112.76. If those 30 students were the whole population under discussion, they would divide by 30 and give 109. Name the population before you divide, and say which one you used when you report the number.
The choice matters most at small N. With 30 students the two answers differ by about 3.5%. With 8 students the gap would be about 14%, and with 5 it would be 25%. Small samples punish a wrong divisor. The sample versus population guide works the same choice through with raw data.
Three slips cause nearly every wrong grouped variance. First, using a class limit instead of the midpoint: putting every 10-20 mark at 10 or at 20 pushes the mean and the spread to one side. Second, forgetting the frequencies: averaging the squared distances without weighting treats a class of 12 like a class of 2. Third, dividing by the number of classes: the divisor counts values, 30 here, not rows, 5. And remember what the answer is: an estimate built on midpoints, not the exact variance of the lost raw data.
That is the whole method. Replace each class by its midpoint, weight by frequency, and run the ordinary variance calculation. The grouped data mean calculator runs the same midpoint method for the mean on your own classes, and the variance calculator shows the same deviation table for raw data, with every step on display.
Frequently asked questions
Can I calculate variance from grouped data without the raw numbers?
Yes. Replace each class by its midpoint, weight by its frequency, and run the ordinary variance calculation. The result is an estimate of the true variance, not the exact value, because the midpoints stand in for the unknown positions inside each class.
Why the midpoint and not the class limits?
The midpoint is the neutral stand-in for the whole class. Using the lower limit would pretend every value sat at the bottom edge, and using the upper limit would pretend they all sat at the top. Both push the mean and the spread to one side; the midpoint assumes the values spread evenly around the centre.
Do I divide by N or by N minus 1 for grouped data?
The same rule as raw data. Divide by N when the classes hold the whole population, and by N minus 1 when they hold a sample. In the exam example the two give 109 and 112.76, so name which one you used.
How accurate is grouped variance?
Usually within a few percent when the classes are sensibly narrow: the example with ten known numbers came out 2% low. Grouping smooths the data, so the estimate usually lands slightly below the exact value. If the raw data still exist, calculate from them instead.
How do I calculate grouped variance in Excel?
Put midpoints in one column and frequencies in the next, then use SUMPRODUCT. With midpoints in A2:A6, frequencies in B2:B6 and the mean in C1, the sample variance is =SUMPRODUCT(B2:B6,(A2:A6-$C$1)^2)/(SUM(B2:B6)-1). The population version divides by SUM(B2:B6) instead.