# Generate a truncated lognormal distribution given mean, variance, lower bound and upper bound?

Basically, I would like to generate a sample of truncated lognormal distribution given mean, variance, lower bound and upper bound. Note that the mean and variance here are the mean and variance of the truncated lognormal distribution NOT the $$\mu$$ and $$\sigma$$.

I tried to find the underlying $$\mu$$ and $$\sigma$$ using the formula in the paper:

A Left and Right Truncated Lognormal Distribution for the Stars

Note that m = exp($$\mu$$) in this paper.

Basically I tried to solve the equation system of which the unknown variables are $$\mu$$ and $$\sigma$$:

1.Mean($$\mu$$, $$\sigma$$, $$x_l$$, $$x_u$$) = desired mean

2.Variance($$\mu$$, $$\sigma$$, $$x_l$$, $$x_u$$) = desired variance

But it seems that this equation could is too complicated for MATLAB to solve. I was wondering if there is a more efficient way to generate a truncated lognormal distribution given mean and variance?

Any help would be greatly appreciated!

• This is an interesting problem and I looked at the possibility to reverting to the truncated Normal for which the moments are easily defined but to no avail... I suggest you consider a more advanced optimisation method to deduce the value of $(\mu,\sigma)$ from the first two moments. Jul 16, 2022 at 15:53
• Thanks for the hint. Could you please specify some possible optimization methods if you don't mind? I think the most naive approach is to create a grid for $\mu$ and $\sigma$ and find the best pair that match the mean and variance. Do you have a better idea regarding this? Jul 16, 2022 at 22:53
• I played around with this, but it seems that different means and variances can lead to similar truncated distributions, so that the problem is not numerically stable. If you know not just the bounds of the truncation, but also how often variables are left-truncated and how often they are right-truncated (which seems likely to be known in most applications) then the problem would be much easier. Aug 8, 2022 at 1:50

Update: I have solved this question NUMERICALLY by optimization.

Basically, define a loss function:

loss = $$(desired\ mean - F(\mu, \sigma, x_l, x_u))^2 + (desired\ std - G(\mu, \sigma, x_l, x_u))^2$$

Where the function F and G is the analytical formula of mean and standard deviation of truncated lognormal distribution.

The formula was elaborated in the paper: Zaninetti

Minimizing this loss function could solve this problem numerically.

Thank you so much for the help!