# How do I calculate the standard deviation of a normal distribution given the mean and a quantile value of that distribution?

How can I determine the standard deviation of a normal distribution with known mean and a known percentile value?

The known percentile value would be on the correct side of the mean (eg, for percentile > 0.5, the value > mean), and the percentile would not be 0.5, as that would simply be equal to the mean, and therefore would tell one nothing about the variability.

This is an R function I use occasionally to do this; is there an analytic or arithmetic method/formula that could solve this? Would it be faster to compute?

#' Determine y in the equation qnorm(mean=m,sd=y,p=p)==x
get_sd_from_quantile_score <- function(m, p, x) {
get_quantile_score <- function(y) {
qnorm(mean=m,sd=y,p=p)
}
f <- function(y) { (get_quantile_score(y) - x)^2 }
opt <- optim(par = 1, fn = f, method = 'CG')
return(opt\$par)
}

• Counterexample: p=0.5 (median) tells you nothing about as. – Tim Oct 9 '19 at 20:29
• Questions asked as code make it hard for the many readers that aren't familiar with the language but would benefit from the answer. Its best to ask the question algebraically. Can you clarify - is the population mean known? – Glen_b -Reinstate Monica Oct 9 '19 at 21:36
• Tim, great counterexample! Glen_b, agreed. The question could be rephrased as "Determine the standard deviation y of a normal distribution with mean m and quantile-p == x when p !=.5 (taking Tim's comment into account)." – ctesta01 Oct 10 '19 at 20:35
• Hi @ctesta01, and welcome to stats.stackexchange. This site allows (and encourages!) editing of questions to improve the question and incorporate new information. I've taken the liberty of editing your question to include the information you provided, but feel free to edit again as needed. – Aaron left Stack Overflow Oct 11 '19 at 14:38

I believe simply (x-m)/qnorm(p) will do it, where m is the known mean and x is the known percentile p. qnorm(p) gives you how many standard deviations away from the mean the value is, and then you scale it by the given difference.

• Ignores @Tim's counterexample posted earlier. In R, qnorm(.5) returns exactly 0. Then what? – BruceET Oct 10 '19 at 21:34
• Especially with the OP's response in comments, I believe that's better added to the question, as a caveat that we know we're doing the computation with meaningful values. – Aaron left Stack Overflow Oct 11 '19 at 14:40

In general, you'll need to know two quantiles of a normal distribution in order to determine $$\mu$$ and $$\sigma.$$

Here is an example based roughly on the part of the Empirical Rule that says about 68% of the probability under a normal curve lies between $$\mu \pm \sigma.$$ Thus quantiles .16 and .84 of $$\mathsf{Norm}(\mu=100,\sigma=15)$$ are roughly at 85 and 115. Computations in R:

qnorm(c(.16,.84), 100, 15)
  85.08313 114.91687

pnorm(c(85, 115), 100, 15)
 0.1586553 0.8413447


By formulating two probabilies with quantiles, standardizing, and using printed tables of the standard normal CDF, you can obtain and solve two equations in unknowns $$\mu$$ and $$\sigma.$$ I will leave details of this self-study problem to you. When you see how it goes, maybe you can evaluate your R functions. Note: If the two quantiles are very close to each other, you may need the additional accuracy that R provides (above printed normal tables) to get accurate values for $$\mu$$ and $$\sigma.$$

• Thanks, but I wasn't asking to determine both μ and σ, just σ. I've accepted Aaron's answer since it correctly answers the question. – ctesta01 Oct 10 '19 at 20:33
• True, but in the code included in the body of the first version of the question, it states that the mean is known as well, which would be the needed second quantile. I've edited the question and the title to include this information. – Aaron left Stack Overflow Oct 11 '19 at 14:42