I need to generate random numbers from 3 correlated distributions. First two of them are lognormal and the final one is normal, i.e. for X, Y and Z I need X and Y to be lognormal, and Z is normal. The correlation matrix is given:
1, -0.8, 0.5
-0.8, 1, -0.5
0.5,-0.5, 1
For example, the std of X and Y and Z are 0.5, 0.3 and 20. The mean of X and Y can be 1, and 0 for Z. How can I do that?
I know I can use https://stackoverflow.com/questions/16024677/generate-correlated-data-in-python-3-3 to generate 3 normally distributed. If all 3 are lognormal distributions, just simply use np.exp. But how can I apply it to my case?
Now my solution is: we can generate multivariate normal distribution of log(X), log(Y) and Z since these 3 variables are normal. However, we need to carefully calculate the elements of the covariance matrix and the vector of mean to ensure the requirements of the mean and std of X and Y and Z.
For mean vector, it is simply [-np.log(1 + std_X ** 2)/2, -np.log(1 + std_Y ** 2)/2, 0] since EX=EY=1. For covariance matrix, based on my calculation, the covariance between \ln X and \ln Y comes from $cov(\ln X, \ln Y)=\ln (1 + \frac{cov(X,Y)}{EXEY}) $. The covariance between \ln X and Z comes from https://stats.stackexchange.com/a/470146/303835.
But is there any simpler method?
-----advanced version
what if I want X and Y and Z all be AR(1) process? I am running EnKF by perturbing atmospheric forcing. Papers just said they made perturbations like this, but I don't know how do it. The data is hourly precipitation, however they said "The time series correlation (temporal correlation) is applied to a first-order autoregressive model." Table 2 shows that they apply a temporal correlation of 24 hours...(https://doi.org/10.1175/JHM-D-15-0037.1)
Thanks!


copulapackage where you can specify the parameters of a Gaussian copula and arbitrary margins. I don't ofhand know which package runs R from Python, but one definitely exists. $//$ Caveat: depending on the margins, the parameters of a Gaussian copula are not necessarily Pearson correlation. – Dave Nov 27 '23 at 16:40