A random number generation algorithm for normal distribution

Source: Internet
Author: User
Tags random seed square root

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.