Hello
Though the subject might seem similar to other subjects available in this forum, it is indeed different. I am doing a Monte Carlo simulation. In each iteration, i have to consider the spatial variability of a parameter(e.g. C) along a curve. in fact, in each iteration the curve is divided to some segments and the random variables (C1,C2, C3, ...,C8) are assigned to each of these segments. Each of these C1, C2, ..,C7 have a lognormal distribution with the same parameters and there is only correlation between C7 and C8 with a correlation matrix like
rho = [ 1,0,0,0,0,0,0,0;
0,1,0,0,0,0,0,0;
0,0,1,0,0,0,0,0;
0,0,0,1,0,0,0,0;
0,0,0,0,1,0,0,0;
0,0,0,0,0,1,0,0;
0,0,0,0,0,0,1,0.2;
0,0,0,0,0,0,0.2,1]
How can i model such a process?
it is worthy to point that, there may be different numbers of random variables in other iterations of Monte carlo simulation (i.e. due to a different curve length) but they all have a lognormal distribution with the same parameters.
Any help/idea/recommendation is highly appreciated.
Best Regards

 Akzeptierte Antwort

Jeff Miller
Jeff Miller am 11 Mai 2021

0 Stimmen

Generate C1-C6 separately (independently) from whatever lognormal you want.
Then generate C7-C8 as a pair with the desired correlation. One easy way to do that is to first generate c7,c8 with mvnrnd and then form C7=exp(c7) and C8 = exp(c8). You just have to adjust the mu & sigma parameters of mvnrnd to get the desired distribution and correlation for C7 & C8,

5 Kommentare

Pooneh Shah Malekpoor
Pooneh Shah Malekpoor am 11 Mai 2021
Bearbeitet: Pooneh Shah Malekpoor am 11 Mai 2021
Could you please explain a bit more? all of the Ci should have the same probability distribution with the same mu and sigma
Shall i produce them at the beginning of the code? In this case, will the statistical properties be retained?
The main point is that you don't need to worry about that big rho matrix because C1-C6 are not correlated with each other or with C7-C8. This makes it much simpler to generate the simulated data values for these variables. For example
mu = 1; % parameter values of the normal distribution log(C)
sigma = 0.1;
n = 100;
c1toc6 = randn(n,6)*sigma + mu;
C1toC6 = exp(c1toc6);
Generating C7 & C8 is more difficult because of the correlation. You can do it with something like this:
rhoN = 0.2;
c7toc8 = mvnrnd([0 0],[1 rhoN; rhoN 1],n)*sigma + mu;
C7toC8 = exp(c7toc8);
Unfortunately, before you start your simulations, you will have to do some pretesting to figure out the right value of rhoN to use here, because the correlation of C7 and C8 will not match rhoN. For the pretesting, use a much larger value of n (say 1000000) and compute corr(C7toC8). This will show you the correlation of C7 & C8 with very little statistical variation due to the large n. So, just use trial and error to figure out what rhoN to use during your simulations so that the underlying bivariate lognormal distribution has the correlation you want (0.2, judging from the big rho matrix in your initial question).
(I do not understand the questions about producing them at the beginning of the code and retaining statistical properties.)
Hope that helps.
Thanks! there is only one question about not getting the same correlation in the samples ( between lognormal C7 and C8). So, i googled a bit and saw there is a relationship for converting the autocorrelation coeffcieint (rhoN to rholn) as
rho(lnC7,lnC8)=(ln(1+rhoN*covC7*covC8))/sqrt(ln(1+covC7^2)(ln(1+covC8^2)))
when i input rholn in the following (instead of rhoN)
c7toc8 = mvnrnd([0 0],[1 rholn; rholn 1],n)*sigma + mu;
the correlation is the same as what i have already defined between C7 and C8.
Is it fine?
Jeff Miller
Jeff Miller am 6 Jun. 2021
I am not familiar with that relationship/equation but it is fine if it gives you the correlation you want between C7 and C8.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by