# Mean and Median properties

Can somebody explain me clear the mathematical logic that would link two statements (a) and (b) together? Let us have a set of values (some distribution). Now,

a) Median does not depend on every value [it just depends on one or two middle values]; b) Median is the locus of minimal sum-of-absolute-deviations from it.

And likewise, and in contrast,

a) (Arithmetic) mean depends on every value; b) Mean is the locus of minimal sum-of-squared-deviations from it.

My grasp of it is intuitive so far. Thank you very much.

-
 So what you're after for the first pair is a proof that the median, as usually defined as the middle-rank value (for an odd number of values anyway, to start with the simplest case) is also the value that minimizes the sum of absolute deviations? Preferably a proof that also gives some intuitive insight? I don't know of any proof myself, so it seems a good question, and one i'd like to know the answer to as well. – onestop Feb 16 '11 at 21:24 You feel me correctly. (a) and (b) are currently separate aspects/properties in my mind, for both statistics; but intuition suggests the two aspects are tied. I want to know - how they are tied, to understand it all deeply. – ttnphns Feb 16 '11 at 23:08

For the computation of the median, let $x_1,x_2,\ldots,x_n$ be the data. Assume, for simplicity, that $n$ is even, and the points are distinct! Let $y$ be some number. Let $f(y)$ be the 'sum-of-absolute deviations' of $y$ to the points $x_i$. This means that $f(y) = |x_1 - y| + |x_2 - y| + \ldots + |x_n - y|$. Your goal is to find the $y$ that minimizes $f(y)$. Let $l$ be the number of the $x_i$ that are less than or exactly equal to $y$ at a given point in time, and let $r = n - l$ be the number that are strictly greater than $y$. Pretend you are 'moving $y$ to the right', that is, increase $y$ slightly. What happens to $f(y)$?

Suppose you add an amount of $\Delta y$ to $y$. For those $x_i$ which are less than or equal to $y$, we have $|x_i - y|$ increases by $\Delta y$. And for those greater than $y$, we have $|x_i - y|$ decreases by $\Delta y$. (This assumes $\Delta y$ is so small that $y$ does not cross any of the points). Thus the change in $f(y)$ is $l\Delta y - r \Delta y = (l-r)\Delta y$. Note that this change in $f(y)$ does not depend on the values of the $x_i$ but only on the number to the left and right of $y$. By definition, $y$ is a median value when moving it to the left or right does not increase or decrease $f(y)$. This would mean that $l-r = 0$, and thus the number of $x_i$ to the left of $y$ is equal to the number to the right of $y$. And thus the median does not depend on the values of $x_i$, just their locations.

edit For the mean: the function $f(y)$ becomes $f(y) = (x_1 - y)^2 + \ldots + (x_n - y)^2$. Clearly the change in $f(y)$ for a small change in $y$ now depends on the magnitudes of the $x_i$, not just the number to the left and right of $y$.

Note that this business about the 'small change' is just covert talk for the derivative of $f(y)$...

-
This sweeps some stuff under the rug concerning when you hit the next $x_i$ value, but is close enough to the handwavey proof desired, I think, at least for the median. – shabbychef Feb 17 '11 at 0:56
thank you for the elegant explication. However, it sounds to me so: "That number y which small change doesn't change function Sum|x_i-y| does not depend on each x_i and is called median". It's an interesting note on median of an even n data. But I was asking to prove this: "That number y which minimizes function Sum|x_i-y| does not depend on each x_i and is called median". And similarly: "That number y which minimizes function Sum(x_i-y)^2 depends equally on each x_i and is called mean". – ttnphns Feb 17 '11 at 13:57
how am I supposed to prove the 'is called median' part? That's crazy. – shabbychef Feb 17 '11 at 20:14
It's a trope of cause. This part is not to prove, I hoped you understand. – ttnphns Feb 19 '11 at 8:31
• Roughly speaking, the median is the "middle value". Now, if you change the highest value (which is supposed to be positive here) from $x_{(n)}$ to $2 * x_{(n)}$, say, it does not change the median. But it does change the arithmetic mean. This shows, in simple terms, that the median does not depend on every value while the mean does. Actually, the median only depends on the ranks. The mathematical logic behind this simply arises from the mathematical definitions of the median and the mean.
• Now, it can be shown that, for any $a \in \mathbb{R}$

$\sum_{i=1}^{n} |x_{i} - median| \leq \sum_{i=1}^{n} |x_{i} - a|$

and

$\sum_{i=1}^{n} (x_{i} - mean)^{2} \leq \sum_{i=1}^{n} (x_{i} - a)^{2}$

-
Well, as an experienced statistician lacking fundamental maths education I still know about Mean and Median differences and applications a lot. What I need here is somebody to DRAW - logically or mathematically - either (a) from (b) or (b) from (a), for me. I feel I can't harmonize (a) with (b) rationally myself. Marco, I find very difficult understanding your notation. If your formulas is the deduction I need please could you "chew over" the idea less technically for me? – ttnphns Feb 16 '11 at 20:59
P.S. As long as your two inequalities got finally displayed correctly on my screen I see it's merely my (b) statements. You write, "it can be shown that...". So do show me that. I need a kind of mathematical proof put in terms that are intelligible for data analyst who is not a professional mathematician. – ttnphns Feb 16 '11 at 22:36
@ttnphns: your request for a mathematical, rather than an intuitive, answer seems incompatible with your request for something less technical than what people have offered. – rolando2 Feb 16 '11 at 23:23
Can we simplify the situation to 2 or three points and ask whether the median in the double summation non-strict inequality above has a unique value? With two points it would seem to be satisfied by any point between the 2. – DWin Feb 17 '11 at 1:03

It is worthwhile to review an older version of the same question:

Why is median age a better statistic than mean age?

And, a description of Robust Statistics:

http://en.wikipedia.org/wiki/Robust_statistics

-