<< distfun_lognpdf LogNormal distfun_lognstat >>

Distfun >> Distfun > LogNormal > distfun_lognrnd

distfun_lognrnd

Lognormal random numbers

Calling Sequence

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

Parameters

mu :

a 1x1 or nxm matrix of doubles, the average

sigma :

a 1x1 or nxm matrix of doubles, the standard deviation

v :

a 1x2 or 2x1 matrix of doubles, the size of R

v(1) :

the number of rows of R

v(2) :

the number of columns of R

m :

a 1x1 matrix of floating point integers, the number of rows of R

n :

a 1x1 matrix of floating point integers, the number of columns of R

R:

a matrix of doubles, the random numbers.

Description

Generates random variables from the lognormal distribution function.

Any scalar input argument is expanded to a matrix of doubles of the same size as the other input arguments.

As a side effect, it modifies the internal seed of the grand function.

Examples

// Set the seed so as to always get the same results.
distfun_seedset(1);

// Test both mu and sigma expanded
computed = distfun_lognrnd(1:6,(1:6)^-1)

// Test sigma expansion
computed = distfun_lognrnd(1:6,2.0)

// Test mu expansion
computed = distfun_lognrnd(1.0,1:6)

// Test with v
computed = distfun_lognrnd(0,1,[3 2])

// Test with m, n
computed = distfun_lognrnd(0,1,3,2)

// Make a plot of the actual distribution of the numbers
mu = 2;
sigma = 3;
data = distfun_lognrnd(mu,sigma,1,1000);
histplot(10,log(data));
xtitle("Lognormal random variables","Log(X)","P");
x = linspace(-10,10,1000);
y = distfun_normpdf(x,mu,sigma);
plot(x,y)

Authors

<< distfun_lognpdf LogNormal distfun_lognstat >>