Apparently, the mean is the value that minimizes the sum of the squares of deviations, and this made sense to me because the sum of the squared differences can be represented as an equation:

(a - x)^2 + (b - x)^2 + (c - x)^2 + ...

This function has a minimum when we take the derivative and solve it when it's equal to zero:

0 = -2(a – x) + -2(b – x) + -2(c – x) + ...

Some more arithmetic will allow us to arrive at the conclusion:

x = (a + b + c + ...) / N

However, I'm having trouble finding a similar way to solve for the median, although I suspect my rusty calculus or arithmetic is behind it.

The sum of absolute deviations would produce the equation:

|a-x| + |b-x| + |c-x| + ...

I think the derivative function would be:

0 = -(a-x)/|a-x| + -(b-x)/|b-x| + -(c-x)/|c-x|

But I am not sure how to continue from here.


1 Answer 1


It looks as if you are looking at a finite set of numbers. Arrange them in order, as $a_1\le a_2\le a_3\le \cdots\le a_n$, on a number line, say the $x$-axis. For the sake of exposition, we will assume that in fact $a_1\lt a_2\lt a_3\lt \cdots\lt a_n$

Start well to the left of $a_1$, and walk very slowly to the right. For a while, if we are at $x$, for every tiny step $h$ that we take, the sum of our distances from the $a_i$ decreases by $nh$. This is true until we hit $x=a_1$. Then a tiny step $h$ increases our distance from $a_1$ by $1$, and decreases the sum of our distances from the others by $(n-1)h$, for a net decrease of $(n-2)h$.

For a while, until we hit $a_2$, every tiny step leads to a net decrease of $(n-2)h$. When $x=a_2$, and we take a tiny step to the right, the net decrease is $(n-4)h$. And so on.

Continue. Now things are a little different if $n$ is even than if $n$ is odd.

If $n=2m$, and we hit $a_m$, then a tiny step to the right increases the sum of the distances from the $a_i$, with $i\le m$, by $mh$, and decreases the sum of the distances from the rest of the $a_j$ by $mh$, for no net change. But then once we hit $a_{m+1}$ and take a further step to the right, the sum of the distances starts to increase. So the minimum is reached at all points between $a_m$ and $a_{m+1}$.

If $n=2m+1$, the same sort of reasoning shows that the sum of the absolute values of the distances reaches a minimum at $x=a_{m+1}$.


Not the answer you're looking for? Browse other questions tagged or ask your own question.