How to prove that the sum of squared differences from the mean is never bigger than the sum of squared differences from the median

inequalitymean square errormeansmedianstatistics

I'm thinking there are $n$ numbers, call them $a_1$ through $a_n$ … with mean $x$ and median $y$. I think it is true that $$\displaystyle\sum\limits_{k=1}^{n} (x-a_k)^2 \leq \displaystyle\sum\limits_{k=1}^{n} (y-a_k)^2$$

In words, this means the sum of squared differences from the mean is never bigger than the sum of squared differences from the median.

I have tested many sets of numbers and this is true for everything I tested. However, I do not know how to prove it.

Best Answer

Hint: Consider $ f(x) = \sum (x - a_k)^2 = nx^2 - (2 \sum a_k)x + \sum a_k^2 $.

When is the minimum of $f(x)$ achieved?

Minimum is achieved at $ \frac{ 2 \sum a_k} { 2n }, $ which is the mean.
Hence the sum of squared differences from the mean is never bigger than the sum of squared differences from any other value, and in particular, the median.

Related Question