File Exchange

image thumbnail

Multivariate Lognormal Simulation with Correlation

version 1.0 (1.98 KB) by

A multivariate lognormal simulator.



View License

MVLOGNRAND MultiVariate Lognormal random numbers with correlation.

This function will generate multivariate lognormal random numbers with correlation.

Often one would simulation a lognormal distribution by first simulating a normal and then taking the exponent of it.

If you provide the correlation matrix to the multivariate normal random number generator and then exponeniate the results, you will not have the correlation stucture you input in the normal distribution because of the exponeniation. This function adjusts for that and passes the adjusted correlation matrix to the normal random number generator.

Mu = [ 11 12 13 ];
Sigma= [ .1 .3 .5 ];
Sims= 1e6;
CorrMat=[1 .2 .4 ; .2 1 .5 ; .4 .5 1];
y=MvLogNRand(Mu,Sigma,Sims,CorrMat );

  ans =
           1 0.19927 0.40156
     0.19927 1 0.50008
     0.40156 0.50008 1

  CorrMat =
         1 0.2 0.4
       0.2 1 0.5
       0.4 0.5 1

Comments and Ratings (9)


It works for me, but the stability is heavily dependent on the variances and on the structure of the correlation matrix. Since it involves the exponentiaion it may be that because of truncation the resulting covariance si not anymore positive definite.

Does somebody has a reference for this method of generating data?

It can be adapted to generate lognormal distributed data with given mean and standard deviation by using the transformation
m = 1;
v = 2;
mu = log((m^2)/sqrt(v+m^2));
sigma = sqrt(log(v/(m^2)+1));

(see Matlab help for lognormal distribution).

Máté Kardos

It's working great for me, many thanks for it!

I tried to use the code with 2 variables but then it is giving an error saying that Sigma should be a symmetric semi-positive definite matrix. Do you have any idea of how I should deal with that?


Dima (view profile)

Nan Shen

question: is the meam and standard deviation normal or lognormal?

Jenny Chew

Tube Event

jane matthew

i need information abaout matlab for lognormal distribution in statistik

ofer setty

MATLAB Release
MATLAB 7.0.1 (R14SP1)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video