Random Number Generation Algorithm

Source: Internet
Author: User

1. Monte Carlo Method

The Monte Carlo method, also known as statistical simulation method and random sampling technology, is a random simulation method based on probability and statistical theory, it is a method that uses random numbers (or more common pseudo-random numbers) to solve many computing problems. Associate the problem solved with a certain probability model and use an electronic computer for statistical simulation or sampling to obtain the approximate solution of the problem. To symbolically show the probability statistical characteristics of this method, the mathematician Feng nuiman named the world-famous gambling city Monte Carlo (that is, Feng nuiman ).
The main steps for solving the Monte Carlo method are as follows:
A. Establish a simple and easy-to-implement probability statistics model based on actual problems so that the desired amount is exactly the probability distribution or digital features of the model.
B. Establish a sampling method for the random variables of the model, conduct a simulation test on the computer, and extract enough random numbers.
C. Conduct statistical analysis on the simulation experiment results and give the "estimation" for the solution ".
D. When necessary, improve the model to improve the estimation accuracy, reduce the experimental cost, and improve the simulation efficiency.

2. Feng nuoman

Von noriman (John von norann, 1903 ~ 1957) One of the most important mathematicians in the 20th century, one of the greatest scientific talents that have made outstanding achievements in modern computer, game theory, nuclear weapons, and many other fields, known as "father of computer" and "father of game theory ". The main contribution is: the binary system idea and the program memory idea. Of course, there is also the Monte Carlo method. The first part shows that Monte CarloMethodMore is the embodiment of an idea (this is far different from the "strict" class such as quick sort.Algorithm). The following describes the most common application -- random number generation.

3. Random generation of U (0, 1)

To simulate a random system, you need to generate a series of random numbers that follow a certain distribution. The most common and basic random number is the random number evenly distributed in the (0, 1) interval. The two most commonly used numerical calculation methods are multiplication and multiplication.

Multiplication Coordinator: it is called a seed. It is a random number in the range of (0, 1.

Hybrid coordinality: where, it is a non-negative integer.

These random numbers are cyclical, and the quality of the random numbers generated varies with the selection of simulation parameters. More complex generation methods include:

4. Random Number from U (0, 1) to other probability distributions

Simulation of Discrete Random Numbers

Set the probability distribution of random variable X to:, the distribution function has

Set random variable U ~ Even Distribution of U (), then,IndicatesThe probability of the random variable U falling between and is the same.

For example, discrete random variable X has a distribution law.

X 0 1 2
P (x) 0.3 0.3 0.4

U is an even distribution of (0, 1), so that the obtained X has the distribution law of X.

Simulation of Continuous Random Variables

There are two common methods: inverse transformation and selection.Inverse Transformation Method
Theorem: let us set the distribution function of the random variable Y to f (y) as a continuous function, and U as a random variable with an even distribution on. In addition, X and Y share the same distribution.

Proof: by definition, the distribution function of X
Therefore, X and Y share the same distribution.
In this way, the random number y is obtained by bringing the uniform distribution U.
For example, set X ~ U (a, B), its distribution function is

. Therefore, the random number u from U (A, B) is generated.

The cumulative distribution function of some random variables does not exist or is difficult to find. Even if it exists, it is difficult to calculate.House Selection Method
To generate a random number, set the value of X to [a, B]. The sampling process is as follows:

1. the random distribution is known and the value range of X is [a, B,

2. Random sampling from them and then sampling from the even distribution.
3. Accept or discard the sample value. If this value is discarded, the previous step is returned. Otherwise, the previous step is accepted. The Geometric Explanation is as follows:

Selection of constant C: C should be as small as possible, because the sampling efficiency is inversely proportional to C; Generally, C is used. Here we can take the even distribution, so that the two even distributions in the second step can be used to obtain the simulation samples with any other distributions.

5. Normal Random Number Generation

In addition to the inverse function method and the selection method above, normal random numbers can also be obtained according to the central limit theorem and box Muller (Coordinate Transformation Method.

Central limit theorem:If the random variable sequence is independent and has a finite mathematical expectation and variance


That is to say, when n independent and same-distribution variables and, obey the normal distribution (N is large enough ).

Where n random variables with independent and same distribution are subject to the Uniform Distribution of U (), then they are subject to the normal distribution.

Box Muller MethodWhere (X, Y) is a pair of random variables that are independent of each other and follow the normal distribution, there is a probability density function:

, Where there is a distribution function:

, The inverse function of the distribution function is :.

If u (0, 1) is evenly distributed, it can be generated by simulation (or even distribution, which can be replaced ). To obey the uniform distribution of U (0, 1 ). D:

Both x and y follow the normal distribution. It is very convenient to use the box Muller method to generate a random number that follows the 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.