File Exchange

## Multivariate Lognormal Simulation with Correlation

version 1.0 (1.98 KB) by

A multivariate lognormal simulator.

Updated

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.

Example:
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 );

corrcoef(y)
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

Edoardo

### Edoardo (view profile)

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

### Máté Kardos (view profile)

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

Katerina Rippi

### Katerina Rippi (view profile)

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

Nan Shen

### Nan Shen (view profile)

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

Jenny Chew

### Jenny Chew (view profile)

Tube Event

jane matthew

i need information abaout matlab for lognormal distribution in statistik

ofer setty

##### MATLAB Release
MATLAB 7.0.1 (R14SP1)