
Although normally distributed random variables are essential for many engineering analyses, software packages usually provide only a function that generates uniformly distributed random samples over the range [0,1]. However, a simple algorithm allows you to convert the uniformly distributed samples into normally distributed samples to a very good approximation.
The algorithm repeatedly takes N samples from the uniform distribution, sums the samples, and then scales and offsets the sum. The summation means that the Central Limit Theorem applies. The theorem states that the distribution of the sum of N random variables, taken from an arbitrary distribution, approaches a normal distribution as N increases.
For uniformly distributed random variables in the range [0,1], summing N=20 samples usually suffices for an engineering approximation of a normal distribution. Offsetting and scaling the sum are necessary because, although the distribution of the sum is approximately normal, the sum may not have the mean and variance desired for your application.
To transform the approximately normal sum's distribution into your desired normal curve, you must find the mean, µ, and standard deviation, ø. Finding the mean and standard deviation using a closed-form solution is very difficult. Fortunately, useful approximations apply.
Because the algorithm uses only N samples from the uniform [0,1] distribution, the sum's mean is obviously N/2. Also the probability of generating a sum outside the range of [0,N] is exactly zero. So, to determine the standard deviation of the approximately normal sum's distribution, the algorithm equates the maximum possible value of the sum of N samples to the 6ø+µ, or "six sigma," point on the normal curve. This approximation yields a standard deviation of ø=(N-µ)/6, which reduces to ø=N/12.
This approximation is valid because the probability of a datum occurring outside the [-6ø-µ,6ø+µ] range is less than 1 in 500 million. For all practical purposes, 1 in 500 million is zero.
Next, assuming that the desired mean, µ´, and standard deviation, ø´, differ from those of the N-sample sums' mean and deviation, transforming the sums takes three steps:
The following equation succinctly expresses the algorithm:
where z is the approximately normal random variable with mean, µ´, and standard deviation ø´ and xi, from i=1 to N, are the samples.
You can easily encode this algorithm as a function in any programming language. The ZIPfile attached to EDN BBS /DI_SIG #16'0 contains a copy of this write-up. (DI #16'0)