ajayshah@alhena.usc.edu (Ajay Shah) (02/02/91)
In article <2181@enuxha.eas.asu.edu> chua@enuxha.eas.asu.edu (M. Chua) writes: > >Hi, all netters. Please advise if there are any subroutine programs that >can be used to generate multivariate normal random numbers. I am >currently using IMSL subroutine RNMVN and would like to know if any other >similar subroutine is available. My 2c worth; only for bivariate normal: --------------------------------------------------------------------------- procedure StdBivNorRand(rho:double; var X1, X2:double); {Generates X1 and X2 which are a draw from a mean-zero bivariate normal distribution with correlation coefficient rho. reference: page 953 of Abramowitch and Stegun} var U1, U2, tmp1, tmp2 : double; begin U1 := random; U2 := random; {warning: generating uniformly distributed random numbers ain't cheap!} tmp1 := sqrt(-2.0*ln(U1)); tmp2 := 2.0*pi*U2; {faster to plug in constant} X1 := tmp1*cos(tmp2); X2 := tmp1*sin(tmp2); {X1 and X2 are now independent, std. normal random numbers. That was cheaper than calling RandNorm twice.} X2 := (rho*X1) + (X2*sqrt(1.0-(rho*rho))) {X1 and X2 are now drawn from the required bivariate normal} end; -- _______________________________________________________________________________ Ajay Shah, (213)734-3930, ajayshah@usc.edu The more things change, the more they stay insane. _______________________________________________________________________________