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.
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.
rnorm
withrcauchy
. $\endgroup$