Products & Services Solutions Academia Support User Community Company

Learn more about Statistics Toolbox   

lognrnd - Lognormal random numbers

Syntax

R = lognrnd(mu,sigma)
R = lognrnd(mu,sigma,v)
R = lognrnd(mu,sigma,m,n)

Description

R = lognrnd(mu,sigma) returns an array of random numbers generated from the lognormal distribution with parameters mu and sigma. mu and sigma are the mean and standard deviation, respectively, of the associated normal distribution. mu and sigma can be vectors, matrices, or multidimensional arrays that have the same size, which is also the size of R. A scalar input for mu or sigma is expanded to a constant array with the same dimensions as the other input.

R = lognrnd(mu,sigma,v) returns an array of random numbers generated from the lognormal distribution with parameters mu and sigma, where v is a row vector. If v is a 1-by-2 vector, R is a matrix with v(1) rows and v(2) columns. If v is 1-by-n, R is an n-dimensional array.

R = lognrnd(mu,sigma,m,n) returns an array of random numbers generated from the lognormal distribution with parameters mu and sigma, where scalars m and n are the row and column dimensions of R.

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 lognstat function. They are:

A lognormal distribution with mean m and variance v has parameters

Examples

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

References

[1] Evans, M., N. Hastings, and B. Peacock. Statistical Distributions. Hoboken, NJ: Wiley-Interscience, 2000. pp. 102–105.

See Also

random, lognpdf, logncdf, logninv, lognstat, lognfit, lognlike

Lognormal Distribution

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS