Rejection method
The rejection method (also acceptance rejection method ; rejection sampling ) is a method for generating random numbers for a given distribution and goes back to John von Neumann . It can be used when the inversion of the distribution function is not possible or too complex.
idea
be the distribution function of the distribution for which random numbers are to be generated. be an auxiliary distribution function for which random numbers can be generated in a simple way - for example using the inversion method. Let it be further and the associated densities .
In order to be able to apply the rejection method, a constant must also exist, so that is satisfied for each . This is needed because the area under a density function is always 1. Without the prefactor, there would inevitably be positions .
Let us now be standard random numbers and random numbers that satisfy the distribution function .
Then the random number of the distribution function is sufficient . In a sense, you are waiting for a first hit that is below .
In other words: random numbers are generated according to the distribution function, and the number becomes with the probability
accepted (acceptance), i.e. when it is the first time . The preceding random numbers are rejected (rejection).
Simple example
In order to choose a random number , whereby each number should occur with the same probability , one can throw a conventional dice . If a 6 appears, you roll again. Usually, however, a number between 1 and 5 (inclusive) will appear on the first throw.
implementation
In terms of programming, the rejection method is generally implemented as the following pseudocode :
function F_verteilte_Zufallszahl()
var x, u
repeat
x := G_verteilte_Zufallszahl()
u := gleichförmig_verteilte_Zufallszahl()
until u * k * g(x) < f(x)
return x
end
The expected value for the number of loop passes is (see below, efficiency ).
Graphic illustration
One can imagine the method in such a way that in the xy-plane between the x-axis and the graph of random points evenly distributed on the surface are scattered. As the x-coordinate of the point , take the G-distributed random number , and the y coordinate is obtained from the standard distributed number : .
Of these random points, those above the graph of ( ) are discarded . The x-coordinates of the remaining points are then distributed according to the density function .
In order to generate a random number according to this distribution, new random points are generated until one is below (point C in the picture). Its x-coordinate is the random number we are looking for.
Efficiency
The area under the density function is 1, and under is the area accordingly . Therefore, standard random numbers and random numbers that suffice have to be consumed on average until the first hit is achieved. It is therefore advantageous if the auxiliary density approximates the density as well as possible so that one can choose small.
literature
- Donald E. Knuth : The Art of Computer Programming . Volume 2: Seminumerical Algorithms. 3. Edition. Addison-Wesley, Reading MA et al. a. 1997, ISBN 0-201-89684-2 , pp. 120ff. ( Addison-Wesley Series in Computer Science and Information Processing ).
- Luc Devroye: Non-Uniform Random Variate Generation . (PDF) Springer-Verlag, New York NY a. a. 1986, ISBN 0-387-96305-7 , p. 41ff.
Individual evidence
- ^ John von Neumann: Various techniques used in connection with random digits. Monte Carlo methods . In: Nat. Bureau Standards , 12, 1951, pp. 36-38.