Simplified Averages - Always true?

62 Views Asked by At

While working on an "average rating" function for a website, I came across an idea for simplified averages, but I want to confirm that it always works. If it does, I might be able to keep a running average (accurately updating the average as new ratings are submitted) while only storing the current average and the number of ratings (rather than storing every rating individually so you can re-average them later).

The question is this: is the average of a given set of numbers always equal to the average of the final number with the average of the rest of the set, included as many times as the rest of the set? In other words, is this ALWAYS true:

AVG(x,y,z) = AVG( AVG(x,y) , AVG(x,y) , z )

or

AVG(a,b,c,d) = AVG( AVG(a,b,c) , AVG(a,b,c), AVG(a,b,c) , d )

and so on, with any number of variables?

One final note: I'm fairly good with math, but I have basically no experience with proofs and such, and the math here is just complex enough for me not to be quite able to answer it definitively myself. Any insight will be appreciated, but bonus points will be given for small words and simple explanations. Thanks!

1

There are 1 best solutions below

0
On BEST ANSWER

Yes, because if $S_{n}=\sum_{k=1}^{n}a_{k},A_{n}=S_{n}/n$, we have \begin{eqnarray*} A_{n} &=&\frac{S_{n}}{n}=\frac{S_{n-1}+a_{n}}{n}=\frac{1}{n}\left( \frac{ S_{n-1}}{n-1}(n-1)+a_{n}\right) \\ &=&\frac{A_{n-1}(n-1)+a_{n}}{n}. \end{eqnarray*}

($A_n$ is the average of the numbers $a_1,a_2,\ldots,a_n$.)