# Percentiles of a distribution

I'm measuring error on the median of my data using bootstrapping. I would like to obtain I sigma error bars on my data, so I'm measuring the 16th and 84th percentiles of my data. Should I divide these percentile values by the square root of the number of data or not? Thanks in advance.

• The sample standard deviation of a median is inversely proportional to the height of the PDF at the median. Thus the 16th and 84th percentiles are irrelevant.
– whuber
Commented May 2, 2013 at 22:11
• BTW, I'm surprised not to see more upvotes for this question: it has attracted three answers, which is prima facie evidence that it is a worthy and interesting question. It's especially remarkable that nobody who has answered has upvoted the question! What's up with that, people?
– whuber
Commented May 2, 2013 at 22:12
• Forgetfulness - my apologies. I am wondering about your first comment. The expected value of the 84th percentile minus the 16th percentile is $2 \sigma$ for a normal distribution, which is the limiting distribution for the sample median. So the poster's proposal of making use of those sample percentiles is an option to be considered. Commented May 3, 2013 at 13:49

Since you are bootstrapping, why not take all of your observed medians and calculate the sample standard deviation $s$ and use that as your estimator of $\sigma$?

• So if I measure s, the error bars on my median are given by σ+s and σ-s, right? Commented May 3, 2013 at 9:29
• $\sigma$ is unknown. If the sample mean of all of your bootstrapped medians is $\bar x$, then if you want to estimate a range of plus or minus 1 standard deviation, you would use the range $\bar x - s$ to $\bar x + s$. Commented May 3, 2013 at 13:33
• Sorry, I just wanted to write x¯ instead of σ. Perfect, thanks a lot! Commented May 3, 2013 at 15:25

If I am understanding your intent, then the answer is "no", don't divide. The sample size is taken into account as part of the bootstrapping process. Of course the values that are using will mostly be meaningful if everything is normally distributed, the fact that you are bootstrapping makes that seem an unlikely assumption. Skewness could really throw this off. Are you dividing the distance from 16th to 84th by 2? If not that could be why you think you need to dived by something.

In general (and good to do here to check if I understood you and even if this method will work for your case) you can answer questions like this through a little simulation. Simulate a data set and do the above analysis, calculate the value both ways and see which is closest to the "true" value from the simulation. Repeat the process with a different sample size, also simulate from different distributions. It should become fairly clear after a few simulations whether to divide or not.

• First of all I have the median of my data (the point I want to plot). Then, after bootstrapping I have the distribution of all the median, which in priciple should be gaussian. So if I want to plot the error bar on the point I have plotted, there are two ways of plotting error bars: 1) measuring the sigma so the errors are median+sigma and median-sigma 2) taking the 16 and 84th percentiles so errors are median-16th and median+84. Should I divide by a factor of 2 in the second case? Commented May 3, 2013 at 7:59
• If you are plotting the error bars then just go from the percentiles without dividing by 2. If you want a numerical estimate of the standard error based on the 16th and 84th percentile, then you would divide the distance between them by 2. Commented May 3, 2013 at 14:05
• Thanks Greg. I also checked median+sigma/median-sigma are more or less similar to 84th-median/median-16th. So the problem is solved. Commented May 3, 2013 at 15:32

Following along the lines developed by Greg and soakley, here's a function that calculates the (bootstrapped) standard errors of an estimate of the median:

median.w.se = function(vec,B){
# Inputs:  vector of data (vec)
#          number of bootstrap replicates (B)
# Outputs: list with estimates of median and standard error
empty.vec = rep(NA,B)
for(i in 1:B){
curr.sample = sample(vec,length(vec),replace = TRUE)
curr.med    = median(curr.sample)
empty.vec[i] = curr.med
}
lst = list(median = mean(empty.vec), se = sd(empty.vec))
return(lst)
}

data(iris)
median.w.se(iris\$Sepal.Length,1000)