# How to calculate mean and standard deviation from median and quartiles

I have 1st quartile, median and 3rd quartile. I want to find mean and SD. I want to use Bland’s method1 but i do not have max, min values of the data. How can i solve this problem? Is there any R package?

1 Bland, Martin. 2014. “Estimating Mean and Standard Deviation from the Sample Size, Three Quartiles, Minimum, and Maximum.” International Journal of Statistics in Medical Research 4 (1): 57–64.

• Without some knowledge of the population distribution you cannot determine the mean. If the mean exists it doesn't even have to fall between the first and third quartile. Jan 16, 2017 at 6:44
• If you have literally nothing else, then why do you think it's either necessary or useful to estimate the mean and SD? What would do with them? Jan 16, 2017 at 13:09
• I recently posted data sets where the mean didn't even lay between the 10th and 90th percentiles... without additional assumptions that rule out such possibilities, this is not going to give sensible answers. Jan 18, 2017 at 11:06
• I'd flag the simple points that one should always (1) flag that this is at best an approximation to be treated very circumspectly (2) cite median and quartiles explicitly or make them accessible otherwise (3) use the spacing of the quartiles around the median as a check on symmetry (4) use what else is known about the measurement scale: even when minimum and maximum are not known there should be some idea of theoretical or likely limits. Aug 29, 2017 at 15:14

You can check Wan et al. (2014)*. They build on Bland (2014) to estimate these parameters according to the data summaries available. See scenario C3 in their paper :

$$\bar{X} ≈ \frac {q_{1} + m + q_{3}}{3}$$

$$S ≈ \frac {q_{3} - q_{1}}{1.35}$$

or, if you have the sample size :

$$S ≈ \frac {q_{3} - q_{1}}{2 \Phi^{-1}\left(\frac{0.75n-0.125}{n+0.25}\right) }$$

where $$q_{1}$$ is the first quartile, $$m$$ the median, $$q_{3}$$ is the 3rd quartile and $$\Phi^{-1}(z)$$ the upper zth percentile of the standard normal distribution.

So, in R :

q1 <- 0.02
q3 <- 0.04
n <- 100

(s <- (q3 - q1) / (2 * (qnorm((0.75 * n - 0.125) / (n + 0.25)))))
#[1] 0.0150441


* Wan, Xiang, Wenqian Wang, Jiming Liu, and Tiejun Tong. 2014. “Estimating the Sample Mean and Standard Deviation from the Sample Size, Median, Range And/or Interquartile Range.” BMC Medical Research Methodology 14 (135). doi:10.1186/1471-2288-14-135.

• No matter how you slice it these papers assume the sample comes fro a normal distribution. Then the population mean=median and of course it is between the 1st and 3rd quartiles! But nowhere did the OP assume normality. Jan 16, 2017 at 14:08
• They test their formulas on normal and skewed data ; but I'm no specialist... Jan 16, 2017 at 14:35

Adding to Michael Chernick's comment, here's an example.

x <- runif(1000,0,1)
summary(x)  #1st Q = 0.27  3rd = 0.77  mean = .51

x1 <- c(x,100)
summary(x1) #1Q = 0.27  3rd = 0.77  mean = .61

x2 <- c(rnorm(100,0,1), rnorm(10,10,.1))
summary(x2)  # 1st = -.85  3rd = 0.69, mean = 0.71


With the first pair, note that a single outlier affects the mean but not the quartiles. The last example is one where the mean is larger than the 3rd quartile.

One real world case where the mean could be greater than the third quartile is income.

There is a detailed publication on this topic from Greco et al, How to impute study-specific standard deviations in meta-analyses of skewed continuous endpoints? World Journal of Meta-Analysis 2015;3(5):215-224.

The main findings of this work are that it is acceptable to approximate "missing values of mean and SD with the correspondent values for median and interquartile range".

If you know that the data is normally distributed, you can infer it given the lower and upper quantiles.

norm_from_quantiles = function(lower, upper, p = 0.25) {
mu = mean(c(lower, upper))
sigma = (lower - mu) / qnorm(p)
list(mu = mu, sigma = sigma)
}


Here, p and 1-p are the quantiles of lower and upper so p = 0.25 is quartiles while p = 0.1 would mean that lower and upper are 10% and 90% quantiles respectively.

I faced similar problem , where i calculated percentiles (0 to 100%) and then I was asked to give back mean as well , after playing in my notebook i noticed that the empirical mean of the quantiles list is in fact the mean of the distribution , thought i discovered a new theorem hahah but then found this

https://en.wikipedia.org/wiki/Inverse_transform_sampling

The theorem established that if you consider F-1 X(w) a random variable and you sample randomly in [0,1] then take the corresponding X , you can generate samples this way from the original distribution , that's why i was getting the mean when computing the quantiles mean . It's not mentioned directly but if you can generate samples of the original distribution then their mean is the mean of the original distribution .

• Although this is sort of correct--both of your methods approximate or estimate the mean, rather than compute it--it doesn't appear to answer the question.
– whuber
May 31, 2022 at 14:52
• That's fine provided you clearly disclose that this is an approximation and is not exactly right. Your statement "is in fact" appears deceptive in that regard. Ordinarily, any good approximation is also accompanied by an estimate of how good it might be.
– whuber
Jun 6, 2022 at 21:24
• When someone claims "1.9 = 2," that statement needs elaboration or else it should just be rejected out of hand. It's that simple.'
– whuber
Jun 7, 2022 at 13:14
• reread my comment , i think i elaborated enough , you remind me of an old teacher of mine , he always used to focus on useless things , instead of teaching me something useful , everyone who reads that understand that it's an approximation , and with the help of my elaboration he understands why it works. Jun 7, 2022 at 13:21