Lognormal random numbers
R = lognrnd(mu,sigma)
R = lognrnd(mu,sigma,m,n,...)
R = lognrnd(mu,sigma,[m,n,...])
R = lognrnd(mu,sigma) returns
an array of random numbers generated from the lognormal distribution
the mean and standard deviation, respectively, of the associated normal
be vectors, matrices, or multidimensional arrays that have the same
size, which is also the size of
R. A scalar input
sigma is expanded
to a constant array with the same dimensions as the other input.
R = lognrnd(mu,sigma,m,n,...) or
= lognrnd(mu,sigma,[m,n,...]) generates an
can each be scalars or arrays of the same size as
The normal and lognormal distributions are closely related. If X is distributed lognormally with parameters µ and σ, then log(X) is distributed normally with mean µ and standard deviation σ.
The mean m and variance v of
a lognormal random variable are functions of µ and σ that
can be calculated with the
A lognormal distribution with mean m and variance v has parameters
Generate one million lognormally distributed random numbers with mean 1 and variance 2:
m = 1; v = 2; mu = log((m^2)/sqrt(v+m^2)); sigma = sqrt(log(v/(m^2)+1)); [M,V]= lognstat(mu,sigma) M = 1 V = 2.0000 X = lognrnd(mu,sigma,1,1e6); MX = mean(X) MX = 0.9974 VX = var(X) VX = 1.9776
 Evans, M., N. Hastings, and B. Peacock. Statistical Distributions. Hoboken, NJ: Wiley-Interscience, 2000. pp. 102–105.
Usage notes and limitations:
The generated code can return a different sequence of numbers than MATLAB® if either of the following is true:
The output is nonscalar.
An input parameter is invalid for the distribution.