🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: sci.math.stat
Article #450

Re: Multivariate normal random number generator

#450
From: Ajay Shah
Date: Sat, 02 Feb 1991 00:58
38 lines
2049 bytes
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.
_______________________________________________________________________________
Technical Details
Message-ID: <29785@usc>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!alhena.usc.edu!ajayshah
References: <2181@enuxha.eas.asu.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!alhena.usc.edu!ajayshah
From: ajayshah@alhena.usc.edu (Ajay Shah)
Newsgroups: sci.math.stat,comp.lang.pascal
Subject: Re: Multivariate normal random number generator
Keywords: Subroutine
Message-ID: <29785@usc>
Date: 2 Feb 91 00:58:55 GMT
References: <2181@enuxha.eas.asu.edu>
Sender: news@usc
Followup-To: sci.math.stat
Organization: University of Southern California, Los Angeles, CA
Lines: 38
Nntp-Posting-Host: alhena.usc.edu