# average of two mean absolute errors equals the mean absolute error over all points?

The mean absolute error (MAE) is defined as: $\frac{1}{n} \sum^n_{i=1} |e_i|$ where $e_i = y - y_{pred}$.

Now if I have two MAEs of $n$ and $N$ samples and take their average, this should be the same as the MAE over all $n+N$ samples:

$$\frac{\frac{1}{n} \sum^n_{i=1} |e_i|+\frac{1}{N} \sum^{n+N}_{i=n+1} |e_i|}{2} = \frac{1}{n+N} \sum^{n+N}_{i=1} |e_i|$$

Is this a correct assumption?

I tried to prove it, however, I didn't get very far.

Can someone show me how to show equality of the left and right-hand side?

• The samples have to be equal ($n=N$) for equality to hold. – Paul Nov 1 '16 at 14:19
• @Paul Ouch... thanks for pointing out the obvious to me =) – Dahlai Nov 1 '16 at 14:24

If the sizes of the two samples aren't equal, you should take a weighted average (assuming we're using the same prediction algorithm on each sample ) . Write $mae:=\frac1n\sum_1^n |e_i|$ and $MAE:=\frac1N\sum_1^N |e_i|$. Then $\sum_1^n|e_i|$ on the first sample is just $n(mae)$, and $\sum_1^N |e_i|$ on the second sample is $N(MAE)$, which means $${\sum_1^n|e_i| + \sum_1^N|e_i|\over n+N}= {n(mae) +N(MAE)\over n+N}$$