Is the following formula right if I want to measure the standard error of the median in case of a small sample with non normal distribution (I'm using python)?
sigma=np.std(data) n=len(data) sigma_median=1.253*sigma/np.sqrt(n)
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It only takes a minute to sign up.Sign up to join this community
Based on some of @mary's comments I think the following is appropriate. She seems to be selecting the median because the sample is small.
If you were selecting median because it's a small sample that's not a good justification. You select median because the median is an important value. It says something different from the mean. You might also select it for some statistical calculations because it's robust against certain problems like outliers or skew. However, small sample size isn't one of those problems it's robust against. For example, when sample size gets smaller it's actually much more sensitive to skew than the mean.
Sokal and Rohlf give this formula in their book Biometry (page 139). Under "Comments on applicability" they write: Large samples from normal populations. Thus, I am afraid that the answer to your question is no. See also here.
One way to obtain the standard error and confidence intervals for the median in small samples with non-normal distributions would be bootstrapping. This post provides links to Python packages for bootstrapping.
@whuber pointed out that bootstrapping the median in small samples isn't very informative as the justifications of the bootstrap are asymptotic (see comments below).
For any distribution other than the normal (and mary admits that this is doubtful in her data), you would have a different factor. Getting the median estimate $\hat m$ is not such a big deal, although you can start agonizing about the middle values for the even number of observations vs. inverting the cdf or something like that. The relevant density value can be estimated by kernel density estimators, if needed. Overall, this of course is relatively dubious as three approximations are being taken:
The lower the sample size, the more dubious it gets.