A good pseudorandom number generator for Monte Carlo integration should have approximately uniform outputs, a period much longer than the intended run, and negligible detectable dependence both serially and in higher-dimensional tuples. It should be fast, reproducible from a seed, portable enough to reproduce a calculation, and numerically precise enough for the required tail probabilities. Values strictly inside avoid singularities in logarithmic inverse transform sampling. Separate simulations also need well-separated streams or seeds, rather than accidentally identical streams. A pseudorandom number generator is deterministic; these properties mean that it imitates independent uniform distributions sufficiently well for the application, not that its outputs are literally independent.
For rate , the exponential distribution has cumulative distribution function on . Inverse transform sampling gives ; since is also uniform, an equivalent answer isFor , , verifying the exponential distribution directly.
The centered Laplace distribution with density can be obtained by multiplying by an independent sign taking and with equal probabilities. Alternatively, its inverse transform sampling formula uses just one uniform variate:The first branch inverts the negative half of the cumulative distribution function and the second branch inverts the positive half. Add a location parameter if a noncentered Laplace distribution is wanted.
Correct uniformity is essential for each marginal distribution, and independence is essential for independent samples and for the sign construction. For example, setting every equal to a single uniform gives uniform marginals but identical transformed draws. Likewise, choosing a sign from the same uniform used for the magnitude can change the Laplace distribution unless the one-uniform inverse above is used.
The first algorithm uses independent normal distributions: generate with law and returnFor example, the Box-Muller transform generates two such normal variates from independent uniforms:To verify this, has density and is an independent uniform angle. Converting the resulting polar density to Cartesian coordinates gives , which factors into two independent normal distributions. Independent pairs therefore give the required sum, discarding a spare coordinate when is odd. Its moment-generating function is , that of the chi-squared distribution.
A genuinely different algorithm uses exponential-envelope rejection sampling for a chi-squared variable. Put . The target and proposal probability density functions areFor , differentiating gives , so the maximum is at . The envelope constant and normalized density ratio areThey remain valid at , where and . Repeatedly draw fresh independent , put , and accept whenThe right side is nonpositive by , so this is a legitimate acceptance probability. The joint probability of proposing and accepting in is ; conditional on acceptance the density is exactly . This proves the rejection sampling algorithm, rather than only identifying the target law.
For I prefer the second method: it reduces to a single exponential draw with no rejection. The first method is simple and attractive when normal draws are already available or is small. For larger , the second method avoids generating normals: its acceptance probability is , asymptotic to by Stirling's formula. Its expected number of proposals grows like , rather than the linear number of normal draws in the first method. Both are exact ideal-uniform algorithms; actual runtime also depends on the implementation.
For Beta sampling by gamma ratios, use either preceding chi-squared distribution algorithm to generate independent and , and returnWrite , so and . The Jacobian determinant is . The joint probability density function after this change of variables factors asIntegrating out proves the Beta distribution for .
A new method is Beta sampling by uniform order statistics. Generate independent uniforms, sort them, and return the th order statistic. There are uniforms below the selected value and above it. Selecting their labels and placing the selected observation in gives densitywhich is the Beta distribution density. The integrality of the shape parameters is what makes this order-statistic construction possible.
Articles by others on the same topic
There are currently no matching articles.