Non-uniform random variate generation


Non-uniform random variate generation or pseudo-random number sampling is the numerical practice of generating pseudo-random numbers that follow a given probability distribution.
Methods are typically based on the availability of a uniformly distributed PRN generator. Computational algorithms are then used to manipulate a single random variate, X, or often several such variates, into a new random variate Y such that these values have the required distribution.
The first methods were developed for Monte-Carlo simulations in the Manhattan Project, published by John von Neumann in the early 1950s.

Finite discrete distributions

For a discrete probability distribution with a finite number n of indices at which the probability mass function f takes non-zero values, the basic sampling algorithm is straightforward. The interval [0, 1) is divided in n intervals f, f + f), ... The width of interval i equals the probability f.
One draws a [Uniform distribution (continuous)">uniformly distributed
pseudo-random number X, and searches for the index i of the corresponding interval. The so determined i will have the distribution f.
Formalizing this idea becomes easier by using the [cumulative distribution function">f, f + f), ... The width of interval i equals the probability f.
One draws a [Uniform distribution (continuous)">uniformly distributed pseudo-random number X, and searches for the index i of the corresponding interval. The so determined i will have the distribution f.
Formalizing this idea becomes easier by using the [cumulative distribution function
It is convenient to set F = 0. The n intervals are then simply F, F), [F, F),..., [F, F). The main computational [task is then to determine i for which FX < F.
This can be done by different algorithms:

Continuous distributions

Generic methods for generating independent samples:
Generic methods for generating correlated samples :
For generating a normal distribution:
For generating a Poisson distribution:

Software libraries

LibraryBetaBinomialCauchyChi-squaredDirichletExponentialFGammaGeometricGumbelHypergeometricLaplaceLogisticLog-normalLogarithmicMultinomialMultivariate hypergeometricMultivariate normalNegative binomialNoncentral chi-squaredNoncentral FNormalParetoPoissonPowerRayleighStudents's tTriangularvon MisesWaldZeta
NumPy
GNU Scientific Library

Literature