Peter-Lawrence . Montgomery on Thu, 13 Apr 2000 07:48:23 +0200 (MET DST)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Gaussian random variables


Bjorn Poonen <poonen@math.berkeley.edu> asks

> Is there any easy way to generate random numbers in GP
> according to the standard normal distribution?
>
    What is `easy'?  Knuth `Seminumerical Algorithm'
gives means to generate normal deviates.  For example,


         1)  Generate two independent random variables U1 and U2,
             uniformly distributed in (0, 1).

         2)  Set V1 = 2*U1 - 1 and V2 = 2*U2 - 1.  Set S = V1^2 + V2^2.

         3)  If S >= 1, return to step 1).

         4)  Set T = sqrt(-2*log(S))/S .

         5)  X1 = T*V1 and X2 = T*V2 are independent,
             normally distributed, with mean 0 and variance 1.