Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a set of values ${x_i}, i=1, \dots ,N$ of which I calculate the median M. I was wondering how I could calculate the error on this estimation.

On the net I found that it can be calculated as $1.2533\frac{\sigma}{\sqrt{N}}$ where $\sigma$ is the standard deviation. But I did not find references about it. So I do not understand why.. Could someone explain it to me?

I was thinking that I could use bootstrap to have an estimate of the error but I would like to avoid it because it would slow down a lot my analysis.

Also I was thinking to calculate the error on the median in this way $$\delta M = \sqrt{ \frac{\sum_i(x_i - M)^2}{N-1} } $$

Does it make sense?

share|improve this question
Do you know with absolute certainty that the data are normally distributed? – gung Feb 15 at 12:48
they are lognormal – A_C Feb 15 at 12:52
Bootstrap should work and it could not take a long time. Either you have a complete enough dataset and no need to do a bootstrap, just take the median of your variable as a good estimation of the real median. Or you have a rather small dataset and you could use bootstrap to estimate a median with your margin error in no excessive time. – YCR Feb 15 at 12:52
Extensive information about the distribution of the median appears in my post at It develops the theory needed for both nonparametric and normal-approximation confidence intervals. – whuber Feb 15 at 19:53
up vote 12 down vote accepted

To directly deal with error on the median you can use the exact nonparametric confidence interval for the median, which uses order statistics. If you want something different, i.e., a measure of dispersion, consider Gini's mean difference. Code is here for the median's confidence interval.

share|improve this answer
I was actually considering to use an analog of the Gini coefficient: $S_n=c * med_j (med_j |x_i-x_j|)$ as defined by Rousseeuw and Croux (…). – A_C Feb 15 at 13:48
The median must have an asymmetric error if the data distribution is asymmetric. – Frank Harrell Feb 15 at 14:19

As pointed out in the other answer, there is a non-parametric CI for the median using the order statistics. That CI is better in many aspects than what you found on the net.

Now, if you must know where the $1.2533\frac{\sigma}{\sqrt{N}}$ factor comes from, the answer is from the asymptotic distribution of the median. If we denote the sample median by $\tilde{\theta}$ and the population median by $\theta$ then it can be shown that

$$\sqrt{n} \left( \tilde{\theta} - \theta \right) \xrightarrow{L} \mathcal{N} \left(0, \frac{1}{4 \left[f \left( \theta \right) \right]^2} \right)$$

where $f$ is the distribution of your sample. The result is not as universal as the CLT because the asymptptic distribution still depends on the underlying distribution of your sample (through the term $\left[f \left( \theta \right) \right]^2$). You can, however, make the drastic simplication that your sample comes from a normal distribution with mean -and median- $\theta$ and variance $\sigma^2$. Evaluating $f$ at its point of symmetry then yields

$$\left[f \left( \theta \right) \right]^2 = \frac{1}{2\pi \sigma^2}$$

and so the asymptotic variance becomes

$$\frac{2\pi}{4} \sigma^2$$.

Divide by $N$ and take the square root of that to arrive at your standard error $1.2533\frac{\sigma}{\sqrt{N}}$.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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