MATLAB Answers

Use 'trandn' function to draw random numbers from a lognormal distribution

7 views (last 30 days)
Shlomit Sharoni
Shlomit Sharoni on 27 May 2020
Commented: Shlomit Sharoni on 27 May 2020
Hi,
Is it possible to use the function 'trandn' to draw random number from a lognormal distribution?
For example:
mu=2;
sigma=1;
upper_bound=10;
Thanks

  0 Comments

Sign in to comment.

Answers (1)

Jeff Miller
Jeff Miller on 27 May 2020
An easy way to get random numbers from a lognormal distribution is to get random numbers from a normal distribution and then exponentiate them. So you could use trand to generate truncated normals (rn) and then form rln = exp(rn).

  1 Comment

Shlomit Sharoni
Shlomit Sharoni on 27 May 2020
Hi,
Thanks for the reply, however, I am not sure that conduct a normal distribution, and exponent the results, is like conduct a lognormal distribution..

Sign in to comment.