Solved – Why does mean tend be more stable in different samples than median

meanmediantypes-of-averages

Section 1.7.2 of Discovering Statistics Using R by Andy Field, et al., while listing virtues of mean vs median, states:

… the mean tends to be stable in different samples.

This after explaining median's many virtues, e.g.

… The median is relatively unaffected by extreme scores at either end of the distribution …

Given that the median is relatively unaffected by extreme scores, I'd have thought it to be more stable across samples. So I was puzzled by the authors' assertion. To confirm I ran a simulation — I generated 1M random numbers and sampled 100 numbers 1000 times and computed mean and median of each sample and then computed the sd of those sample means and medians.

nums = rnorm(n = 10**6, mean = 0, sd = 1)
hist(nums)
length(nums)
means=vector(mode = "numeric")
medians=vector(mode = "numeric")
for (i in 1:10**3) { b = sample(x=nums, 10**2); medians[i]= median(b); means[i]=mean(b) }
sd(means)
>> [1] 0.0984519
sd(medians)
>> [1] 0.1266079
p1 <- hist(means, col=rgb(0, 0, 1, 1/4))
p2 <- hist(medians, col=rgb(1, 0, 0, 1/4), add=T)

As you can see the means are more tightly distributed than medians.

enter image description here

In the attached image the red histogram is for medians — as you can see it is less tall and has fatter tail which also confirms the assertion of the author.

I’m flabbergasted by this, though! How can median which is more stable tends to ultimately vary more across samples? It seems paradoxical! Any insights would be appreciated.

Best Answer

The median is maximally robust to outliers, but highly susceptible to noise. If you introduce a small amount of noise to each point, it will enter the median undampened as long as the noise is small enough to not change the relative order of the points. For the mean it's the other way around. Noise is averaged out, but a single outlier can change the mean arbitrarily.

                                        mean  median   
original   [1.0, 2.0, 3.0, 4.0, 5.0]       3       3
noise      [1.1, 1.9, 3.1, 4.1, 4.9]    3.02     3.1
outlier    [100, 2.0, 3.0, 4.0, 5.0]    22.8       4

Your test mostly measures robustness to noise, but you can easily create a sample where the median performs better. If you want an estimator that is robust to both outliers and noise, just throw away the top and bottom third and average the remainder.