For calculating the Absolute Mean Error, can the absolute be outside the sum?

31 Views Asked by At

The question simply put, is the following true?

$$ \frac{1}{n}\sum_{i=1}^n |x_i-y_i| = |\frac{1}{n}\sum_{i=1}^n (x_i-y_i) | $$

The left part is the Mean Absolute Error. In the right case, the only difference is that the absolute is around the mean.

Question 1: I want to know if the above two are equal.

The reason I want to know that is because when given some datasets (for x and y), the above two give the same result.

Question 2: If they are not equal, what does it mean that the result is exactly the same?

Thanks in advanced.

1

There are 1 best solutions below

1
On BEST ANSWER

The two are not equal. Let $z_i = x_i - y_i$. For instance, choose $x_1 = -x_2 = 1$, all the other zeros. Then you get 0 on the left, and $\frac{2}{n}$ on the right.

The equality holds if and only if all the $z_i$'s have the same sign (either they are all positive or all negative).