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 .
For , use the unnormalized normal density . Its ratio region is
The bound on is one because is maximized at zero. To bound , maximize for . Its derivative vanishes at , giving . Thus the normal ratio-of-uniforms envelope is , .
Draw independent , set and , and accept precisely when
returning . Equivalently compare logarithms to avoid underflow. Since , the region area is and the rectangle area is . Therefore
It is independent of the normal scale. In the diagram the vertical coordinate is normalized by , so the same shape works for every positive scale.
Figure 1.
Normal ratio-of-uniforms region and its minimum axis-aligned rejection rectangle
. Details.