lundi 1 juin 2020

Generating Correlated Random Samples

I read this tutorial https://scipy-cookbook.readthedocs.io/items/CorrelatedRandomSamples.html on how to get a matrix C so that C*C^T = R, with R being a given covariance matrix. The code example implements two differents methods, Cholesky decomposition or using the eigenvalues. To my suprise printing the resulting C of the two different methods gives me two different matrices:

Eigenvalue method result:

[[ 0.11928653 -0.86036701  1.6265114 ]
 [ 0.00835653 -0.89810227 -2.16641235]
 [ 0.18832863  0.58480336 -0.93409708]]

Cholesky method result:

[[ 1.84390889  0.          0.        ]
 [-1.4913969   1.80989925  0.        ]
 [-1.08465229 -0.06500199  0.26325682]]

If someone could explain to me why the two resulting matrices are different I would be very grateful.




Aucun commentaire:

Enregistrer un commentaire