Print

Print


This is the simplest way.
Best,
Matteo

#include <oxstd.oxh>

main()
{
     decl cn = 10000; // sample size
     decl vMu = <1;2;3>; // mean vector
     decl mSig = <5, 3, 1;
                  3, 6, 2;
                  1, 2, 7>; // covariance matrix

     decl mZ = rann(cn, rows(mSig));     // generate n x k matrix of 
standard normal variates
     decl mX = mZ*choleski(mSig)'+vMu';  // factorise covariance matrix 
by choleski and multiply standard normals, then sum means

     println("Actual vs. estimated mean vector", vMu', meanc(mX));
     println("Actual vs. estimated covariance matrix", mSig, variance(mX));
}

Il 13/07/2015 23:23, Natalia Manduca Ferreira ha scritto:
>
>   Dear collegues,
>
>   I need to generating multivariate normal random variables, but I 
> don't know how. Could anyone help me?
>
>   Very thank you!
>
> -- 
>     Natalia Manduca

-- 
Matteo Pelagatti
Department of Economics, Management and Statistics
Università degli Studi di Milano-Bicocca
Tel +39 02 64485834