B prev next
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

<< RANDOM DISTRIBUTIONS >>

The Rejection Method

Example: Consider that we want the distribution
Py(y) = exp( -y ) y 2 in the range y = 0 to 10. Maximum value of the function, Pymax, is found from:

dPy/dy = 0

The function has a maximum value at y = 2 which corresponds Pymax = 0.541. Ptest is therefore generated from 0 to 2.


The computer implementations of the algoritm for 40,000 events:
Fortran 90   rejection.f90 histogram.f90 rejection.fout
ANSI C   rejection.c histogram.h rejection.cout