# Sum of averages vs average of sums

I have essentially a table of numbers -- a time series of measurements. Each row in the table has 5 values for the 5 different categories, and a sum row for the total of all categories.

If I take the average of each column and sum the averages together, should it equal the average of the rows' sums (ignoring rounding error, of course)?

(I've got a case where the two values keep coming out different by about 30% and I'm wondering just how crazy I am.)

Update: See below -- I was (slightly) crazy and had an error in my code.

-
Is the number of rows 14? –  Aryabhata Feb 3 '12 at 23:09
Actually, it's an exponential moving average with N of 50. –  Daniel R Hicks Feb 3 '12 at 23:13
(That is, the vertical time dimension is calculated with a moving average. FWIW, the column values tend to differ by a factor of 50 or so, with one column predominating.) –  Daniel R Hicks Feb 3 '12 at 23:20
In an earlier comment, I was referringg to a different problem. If in your table there are blanks (no entry) then the averages can differ. –  André Nicolas Feb 3 '12 at 23:25
@DanielRHicks: Maybe you have a bug in your code? I (blindly, and without reading your question properly) guessed that you took the sum of row averages and compared that with the sum of the column averages (hence a guess of 14). –  Aryabhata Feb 3 '12 at 23:26

The average of the entries in a column is the sum of the entries in that column, divided by the number of entries. The number of entries is the number of rows. So the sum of the averages is the sum of all the entries in the table, divided by the number of rows.

The average of the row sums is the sum of all entries in the table divided by the number of rows, so you should get the same number either way.

-

Sigh!! Found my problem -- it was a stupid "dupe error" in my code. I was looking for an error in the "average of sums" logic, but it was in the "sum of averages" logic -- referencing the wrong variable.

Well, anyway, we've demonstrated about 5 ways from Sunday that the sum of averages really IS equal to the average of sums, in case that's important to anyone in the future.

-
Perhaps this should go as an update to the question? Either way is fine though. Also be sure to accept an answer now that your issue is resolved. –  Zev Chonoles Feb 7 '12 at 2:15

Actually Steve could be correct. I'll give you a simple example and then explain why intelligent people can come up with different answers because in a way, they're both "right."

First row: 5; 6; Second row: 1; 2; Third row: 3; 4;

If you do either the sum of the averages or average of the sums as Daniel asked, then you'll get 7 as the answer. If however, you remove the 1 leaving a hole in your table, then your average of the sums drops to 6 2/3 and your sum of the averages increases to 8.

If your table of data has blanks or missing data points, then the two are almost never the same. If the table of data is equally/evenly distributed without any missing points or holes in the table, then they should always be the same. Anybody can test this out with MS Excel and the =RAND() function. Generate a table with any number of rows/columns and fill in the rows and columns with random numbers or let it generate random numbers for you. Then use =AVERAGE() to average the columns and =SUM() to add up the averages. Then reverse the process and use =SUM() to add the rows and =AVERAGE() to average the sums. If the table is complete, then the two numbers will be precisely the same. If however, your data for any reason is missing entries, then it can vary by a great percentage. Just start deleting data points in the middle of the table and watch the two results greatly fluctuate.

Also of notes is if you flip the rows and columns then you get completely different results, so make sure you're consistent. If you average the rows in the above example and sum the averages, or sum the columns and average the sums, then you get 10.5 with a complete table and 11 and 10, respectively with the 1 missing.

-
Note that OP wrote in one of the comments that there are no blanks in the table. Note also that if Steve's answer is deleted then no one will know what your first sentence means. –  Gerry Myerson Aug 7 '12 at 1:04

mixed math is correct. take 3 columns; 10 10s, 5 1s and 2,3,5,6,6,7,9,10 (8 values from rand), don't average blanks. avg of avgs is 5.67; avg of all values is 6.65. @Mixed math; it is ok to answer an old thread. This stuff, truth or truthy, lives forever on the internet

-

Generally no is correct, it is only the same in specific cases.

ie. Generally

Sum(x) / Sum(y) not equal to Sum (x/y) / n

where n is the total entries x is row entries and y is column entries.

only true if all of the y's are equal

eg: (1/2 + 3/5)/2 = 11/20 (1+3)/(2+5) = 4/7

Where as if y is equal (1/7 + 4/7)/2 = 5/14 (1+4)/(7+7) = 5/14

PS Sorry about posting on dead thread just want it to be right for anyone else looking.

-

If I take the average of each column and sum the averages together, should it equal the average of the rows' sums (ignoring rounding error, of course)?

Generally, no.

-
Is there a reason why you thought that answering a months-old question with this answer would be a good thing to do? –  mixedmath May 23 '12 at 4:04
Because the final conclusion is absolutely wrong. This is a fairly well known result that the sum of the averages is not equal to the average of the sums. Sure it is a thread necro, but at the same time it is correcting a demonstrably wrong statement. –  Steve Verdon May 23 '12 at 16:09
Perhaps you should come up with that example, of a n by n table, with no blanks, and whose average is different than the sum of the averages of the rows. –  mixedmath May 23 '12 at 18:03
@SteveVerdon No, the distributive property easily shows that the sum of the averages is the average of the sums. Gerry's answer is correct. –  Alex Becker May 24 '12 at 17:23