RandomNumbers

RandomNumbers

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 4.3 Box-Muller algorithm In many cases the integral to calculate the CDF may not be easy to calculate analytically and we need to come with clever algorithms. For example there is no closed form formula 2 x for the integral of the normal distribution I = 21 −∞ e−x /2 dx . π The Box Muller method is a brilliant trick to overcome this by producing two independent standard normals from two independent uniforms. It is based on the familiar trick for calculating this integral: I2 = ∞ −∞ e−x 2 /2 ∞ dx −∞ e−y 2 /2 ∞ dy = ∞ −∞ −∞ e(x 2 +y 2 )/2 dxdy This integral can be calculated using polar coordinates x = r cos(θ), y = r sin(θ) with vii area element dxdy = rdrdθ, so that ∞ I2 = 2π e−r 2 /2 ∞ e−r rdrdθ = 2π r=0 θ=0 2 /2 rdr r=0 Substituting s = r2 /2 gives ds = rdr and ∞ I 2 = 2π e−s ds = 2π s=0 Now, lets look at the integral of the distribution on r where r is defined above and then use the inverse trick. r 2π U= r =0 θ=0 1 −r 2/2 e r dr dθ = I 2 (x, y ) 2π Using the same variable transformation s = r2 /2 we can show r2 /2 U= e−s ds = 1 − e−r 2 /2 s=0 where U is the uniformly distributed variable. (We have changed the notation since r is now used for radius). Notice that since r goes from [0, ∞], U is uniformly distributed on [0, 1], and no rescaling is required. We can solve for r but it is easier first to observe that U1 = 1 − U is also uniformly distributed. Therefore we can solve the following equation: 1 − e−r 2 /2 = 1 − U1 and find r as a function of U1 . r= −2 ln U1 Also note that θ is uniformly distributed from 0 to 2π and θ = 2πU2 Altogether, the Box Muller method takes independent standard uniform random variables U 1 and U 2 and produces independent standard normals x and y using the formulas θ = 2πU2 5 r= −2 ln U1 x = r cos θ y = r sin θ Rejection Method A simple method for generating random points with distribution w(x) was deduced by von Neumann. The idea is extremely simpl...
View Full Document

This document was uploaded on 10/07/2013.

Ask a homework question - tutors are online