For the unnormalized Laplace distribution probability density function , the ratio-of-uniforms method uses . The maximum of is one. On , the maximum of occurs at and equals . On , it occurs at and equals . Thus the displayed rectangle contains the region. Its area is , while the target region has area . Uniform proposals in the rectangle, accepted when , therefore return the correct Laplace distribution with acceptance probability .
Integrating out the second coordinate gives the probability density function of the marginal distribution
Thus the ratio has the normalized target probability density function. The factor from the Jacobian determinant is essential; merely transforming the rectangular coordinates as if they remained uniform would give a different probability density function. This is the basis of the ratio-of-uniforms method.
For , use the unnormalized normal shape . The ratio-of-uniforms method samples uniformly from
Its boundary is . The largest possible occurs at and equals , giving the normal ratio-of-uniforms envelope , .
Use independent uniform pairs to propose and . Accept precisely when
To verify its distribution, change coordinates from to , with and Jacobian determinant . The accepted point is uniform on , and the marginal probability density function of is proportional to
Thus the result is . The region has positive finite area , and the acceptance probability is . The case requires simply returning zero.
Use the ratio-of-uniforms method on
Writing gives and . Consequently
because the derivative vanishes at . Thus the normal ratio-of-uniforms envelope is the rectangle , .
Generate independent with uniform distribution on , set and , and accept precisely when
Reject and repeat otherwise. On acceptance return . One can compare logarithms instead of exponentials to avoid underflow.
For a proof, the change of variables has Jacobian determinant . A uniform point in therefore gives an -density proportional to
Normalizing yields the required normal distribution with mean zero and variance . The region area is ; dividing it by the rectangle area gives acceptance probability .
Let be proportional to the target probability density function, with . Define the ratio-of-uniforms method through the region
Draw uniformly with respect to area on and return . To prove its law, change variables from to . The Jacobian determinant is , and the allowed interval for is . Consequently
The joint density of is therefore on that interval. Integrating out gives
For an already normalized density, and the region has area . The name refers to the two coordinates of a uniformly sampled region; drawing two unrelated uniforms on arbitrary intervals and taking their ratio would not give the target law.