A random number generation algorithm for normal distribution
All of the above is a distributed random number generation algorithm, in scientific and engineering applications, the random number of normal distribution is often used. For a given normal distribution, the parameters describing the normal distribution include mean μ and variance, mathematically, an approximate algorithm for generating a normal distribution is as follows:
An RI is a random number evenly distributed between [0,1]. When n tends to infinity, the resulting random distribution is normal. For a more detailed mathematical discussion of this algorithm, readers can refer to the books related to probability statistics, which will be referenced directly here.
It is impossible to take n as Infinity in practical application. In general, N is large enough to do it. In order to calculate the convenience, you can take n=12, so that the square root in the denominator can be ignored, and the results obtained are sufficient to form a normal distribution.
According to the above algorithm, we can write the random number generation algorithm with normal distribution, the code example is as follows:
In the above code, the input parameter u is the normal distribution of the mean μ, the input parameter T is the variance of the normal distribution, the input parameter r is a random seed in the program, using the previous [0, 1] The uniform distribution between the random number algorithm rand0l ().
The following is a complete example of how to generate the required normal distribution random number. Suppose the desired normal distribution mean value//=2.0, variance = 3.52. The complete program code example is as follows:
Http://www.manonggu.com/suancheng/view653.html
A random number generation algorithm for normal distribution