Your question is: how can you compute the std dev of grouped data?
I suggest that we take a simpler example to facilitate verification.
Consider the following in A1:A3 and B1:B3:
3 50
4 3
5 100
The std dev and avg can be computed easily by
STDEVP({50,50,50,3,3,3,3,100,100,100,100,100}) and
AVERAGE({50,50,50,3,3,3,3,100,100,100,100,100}). Note that I use STDEVP
instead of STDEV. I am assuming that A1:B3 represents all of the data, not
a sampling.
More generally, STDEVP of the grouped data can be computed by:
=SQRT(SUMPRODUCT(A1:A3,(B1:B3-X1)^2) / SUM(A1:A3))
where X1 is the average computed by:
=SUMPRODUCT(A1:A3,B1:B3) / SUM(A1:A3)
Compare these results with teh STDEVP and AVERAGE results.
Note: You could substitute the latter formula for X1 in the first formula,
but I think it would be less effiicient. You may or may not see a
difference when you have "thousands" of groups. But in any case, I think
the first formula is more readable as is.
If you want to compute STDEV instead of STDEVP, replace SUM(A1:A3) with
(SUM(A1:A3)-1) -- note the parentheses -- in the first formula only. The
average is still computed by dividing by SUM(A1:A3).
----- original message -----