I would like to create correlated multivariate normal random numbers. It is my understanding that this can either be done using the Statistic Toolbox function mvrnd or by using randn with a Cholesky decomposition of the covariance matrix (sigma).
rng('default')sigma = [1 .5;0.5 1];R = mvnrnd(zeros(100,2),sigma);R2 = randn(100,2)*chol(sigma);corrcoef(R)corrcoef(R2)
However, above code gives me different random numbers (although they do exhibit the desired correlation). Why is this the case? Is their a difference between using mvnrnd() and randn()*chol()?
Best regards, Florian
Best Answer