# How to calculate a mean and standard deviation for a lognormal distribution using 2 percentiles

I am trying to calculate a mean and standard deviation from 2 percentiles for a lognormal distribution.

I was successful in performing the calculation for a normal distribution using X = mean + sd * Z and solving for mean and sd.

I think I am missing an equation when I try to do the same thing for a lognormal distribution. I looked at wikipedia and trying to use ln(X) = mean + sd * Z but I'm getting confused whether the mean and sd in this case are for the normal distribution or the lognormal.

Which equations should I be using? and will I need more than 2 percentile to solve the calculations?

• Welcome to the site, @Jean-Francois. Note that if you only wanted R programming help, this question would be off-topic for CV (see our help page). I think this has enough statistical content to be on-topic here, but it is close to the border. It might help if you could formulate it in a more software-neutral way, & you may need to be ready for answers that address the statistical issues but are not R specific. Commented Dec 11, 2013 at 2:44
• I will reformulate. I was trying to solve it with R, but I think I'm missing a fundamental concept here which is why I'm not getting the results I'm expecting.
– J-F
Commented Dec 11, 2013 at 14:47

It seems that you "know" or otherwise assume that you have two quantiles; say you have that 42 and 666 are the 10% and 90% points for a lognormal.

The key is that almost everything is easier to do and understand on the logged (normal) scale; exponentiate as little and as late as possible.

I take as examples quantiles that are symmetrically placed on the cumulative probability scale. Then the mean on the log scale is halfway between them and the standard deviation (sd) on the log scale can be estimated using the normal quantile function.

I used Mata from Stata for these sample calculations. The backslash \ joins elements column-wise.

mean = mean(ln((42 \ 666)))

(ln(666) - mean) / invnormal(0.9)
1.078232092

SD = (ln(666) - mean) / invnormal(0.9)


The mean on the exponentiated scale is then

exp(mean + SD^2/2)
299.0981759


and the variance is left as an exercise.

(Aside: It should be as easy or easier in any other decent software. invnormal() is just qnorm() in R if I recall correctly.)

• Thanks a lot Nick. So much simpler when you go back to basics. The only change I made was on your last line exp(mean + SD^2); I changed it to exp(mean + (SD^2)/2)
– J-F
Commented Dec 11, 2013 at 20:52