Unorthodox way of getting the average of two numbers

I can't believe the alternative method I just saw to calculate the average of two numbers:

I use the following:
(a+b)/2 = avrg(a,b)
(b+a)/2 = avrg(a,b)

Found someone using this:
a+((b-a)/2) = avrg(a,b)
b+((a-b)/2) = avrg(a,b)

How to calculate avrg(a,b,c) using the second method? (e.g for the first one is (a+b+c)/3)

How can I transform the first one into the second one, or otherwise find some proof they both are equally equal?


Observe that $$ a+\frac{b-a}{2} = \frac{2a}{2} + \frac{b-a}{2} = \frac{2a+b-a}{2} = \frac{a+b}{2}. $$ You can do the analogous thing for $$ b+\frac{a-b}{2} = \frac{a+b}{2}. $$ And for the average of three numbers $a,b,c$, $$ \operatorname{avg}(a,b,c) = a + \frac{b-a}{3}+\frac{c-a}{3} = \frac{a+b+c}{3}. $$ You can "switch around" the $a,b,c$ above to get three different, but similar, expressions. They are proved to be "equally equal" (as you say!) by the approach we took above for proving equality in the two numbers case.

And you could do this for some $n$ numbers $a_1,\dots,a_n$ as follows: $$ \operatorname{avg}(a_1,\dots,a_n) = a_i+\sum_{k\neq i} \frac{a_k-a_i}{n} = \frac{1}{n}\sum_{k=1}^n a_k $$ for each $i\in\{1,2,\dots,n\}$. Can you show they are equal?? :-)


$$ {\rm avrg}(a,b,c) = a + \dfrac{b-a}{3} + \dfrac{c - a}{3} $$


This is one step in an iterative way of computing the average of $N$ numbers:

Suppose that you have a sequence of $N$ numbers $x_i$. Let

$$ \bar{x}_n = \frac{1}{n} \sum_{i=1}^{n} x_i $$

i.e. the average of the first $n \le N$ of them.

Then $$ \bar{x}_{n+1} = \bar{x}_{n} + \frac{ x_{n+1} - \bar{x}_n}{n+1} $$

I'll leave the proof of this general case to the reader.

This iterative (running) approach for taking the average has advantages when doing numerical computations on a computer.

For $n=2$ $x_i = [a,b]$ you get the form indicated in your question:

$$ \bar{x}_1 = a \\ \bar{x}_2 = \bar{x}_1 + (b-\bar{x}_1)/2 = a+(b-a)/2 $$

For $n=3$, $x_i=[a,b,c]$ you could write this out as

$$ \bar{x}_{2} = a+(b-a)/2 \\ \bar{x}_3 = \bar{x}_2 + (c-\bar{x}_2)/3 $$ I'll leave it to the reader to exand out $\bar{x}_2$ in the final expression.


The method runs as follows:

Pick one number.

Make it the new (false) origin (zero) by subtracting it from all the others.

Now average those residuals.

You can usually average the residuals more easily (especially in your head) by doing the division first, that is, divide each of the residuals by the number of values you have (including the false origin), and then add those results together.

Now add the average of the residuals back to the the number you first chose.

This removal of a false origin can also be useful in real engineering calculations as it makes the values and process more easy to comprehend and check.

There are many maths formulas that pre-weight the offset values to avoid confusion about the apparent number of variables. It's a worthwhile 'trick' to learn ;-)