Page 1 of 1

bivariate normals

Posted: Thu Apr 30, 2015 9:44 am
by startz
The following code is a subroutine that generates bivariate normal series with zero means. Note that since it is a subroutine, it can only be called from a program.

Code: Select all

' Generate bivariate mean zero normals ' Dick Startz ' April 2015 subroutine bivariateNormals(series e1,series e2,scalar sigma1,scalar sigma2,scalar rho) ' return series e1 and e2 with standard deviations sigma1 and sigma2 and correlation rho ' e1 and e2 must be defined as series in workfile. The other parameters are scalars. if abs(rho)>1 then seterr "correlation must be between -1 and 1" return endif e1 = sigma1*nrnd e2 = sigma2*(rho*e1/sigma1 + @sqrt(1-rho^2)*nrnd) endsub

Re: bivariate normals

Posted: Fri Jul 17, 2015 10:31 am
by NicolasR
Hi,

Thanks for the code, I'm using it to run some multivariate simulations, but I have a question, the code is based in the method that use the cholesky decomposition?

Regards.

Re: bivariate normals

Posted: Fri Jul 17, 2015 10:43 am
by startz
Yes