27. Find and implement the most common algorithms for Normal Random Variables generation.
Some existing methods for generating standard normal random numbers discussed in this section.
1. Sum of Uniform Random Variables
The simplest way of generating normal variables is an application of the central limit theorem. The central limit theorem is a weak convergence result that expresses the fact that any sum of many small independent random variables is approximately normally distributed. Use of the central limit theorem on U(0,1) random variables provide a simple method for closely approximating normal random variates. The following algorithm is used to generate the standard normal variables.
1 . Generate 12 independen t uniform random numbers, U 1 , U 2 , K , U 12 ~ iid U ( 0,1 )
2 . Return Z = ∑ U i − 6 . This method requires 12 uniform random variables to generate a single standard normal random number.
2. Box-Muller Method
This method is due to Box and Muller (1958) and generates a pair of independent standard normal random variables using a pair of uniform random numbers as follows:
1. Generate two independent random numbers U 1 and U 2 from U(0,1) distribution.
2. Return Z1 = sqrt(−2lnU1)Cos(2πU2 ) and Z2 = sqrt(− 2lnU1)Sin (2πU2 ) .
### 3. Polar Method
Another form of the Box-Muller method is called the polar technique. This improves over the previous technique in being quicker as well as numerically more robust. The algorithm can be summarized as follows:
1. Generate two random numbers U 1 and U 2 from U(0,1) distribution.
2. Set V1 = 2U1 − 1 , V2 = 2U2 − 1 and S = V1^2 + V2^2 . Note that V 1 and V 2 are U(-1,1).
3. If S>1, go to step 1, otherwise go to step 4.
4. Return two independent standard normal variables
Z 1 =sqrt(−2lnS/S)V1 and Z2 = sqrt(−2lnS/S)V2. This algorithm also requires two uniform variables to generate a single standard normal random number.
4. Inversion Method
This method is due to Hastings (1955) and the algorithm can be summarized as follows:
This method requires single uniform random number but involves seven constants.