The Marsaglia polar method is a pseudo-random number sampling method for generating a pair of independent standard normal random variables. Standard normal random variables are frequently used in computer science, computational statistics, and in particular, in applications of the Monte Carlo method. The polar method works by choosing random points (x, y) in the square −1 < x < 1, −1 < y < 1 until
0 < s = x 2 + y 2 < 1 , {\displaystyle 0<s=x^{2}+y^{2}<1,\,}
and then returning the required pair of normal random variables as
x − 2 ln ( s ) s , y − 2 ln ( s ) s , {\displaystyle x{\sqrt {\frac {-2\ln(s)}{s}}}\,,\ \ y{\sqrt {\frac {-2\ln(s)}{s}}},}
or, equivalently,
x s − 2 ln ( s ) , y s − 2 ln ( s ) , {\displaystyle {\frac {x}{\sqrt {s}}}{\sqrt {-2\ln(s)}}\,,\ \ {\frac {y}{\sqrt {s}}}{\sqrt {-2\ln(s)}},}
where x / s {\displaystyle x/{\sqrt {s}}} and y / s {\displaystyle y/{\sqrt {s}}} represent the cosine and sine of the angle that the vector (x, y) makes with x axis.
Theoretical basis The underlying theory may be summarized as follows: If u is uniformly distributed in the interval 0 ≤ u < 1, then the point (cos(2πu), sin(2πu)) is uniformly distributed on the unit circumference x2 + y2 = 1, and multiplying that point by an independent random variable ρ whose distribution is
Pr ( ρ < a ) = ∫ 0 a r e − r 2 / 2 d r {\displaystyle \Pr(\rho <a)=\int _{0}^{a}re^{-r^{2}/2}\,dr}
will produce a point
( ρ cos ( 2 π u ) , ρ sin ( 2 π u ) ) {\displaystyle \left(\rho \cos(2\pi u),\rho \sin(2\pi u)\right)}
whose coordinates are jointly distributed as two independent standard normal random variables.
History This idea dates back to Laplace, whom Gauss credits with finding the above
I = ∫ − ∞ ∞ e − x 2 / 2 d x {\displaystyle I=\int _{-\infty }^{\infty }e^{-x^{2}/2}\,dx}
by taking the square root of
I 2 = ∫ − ∞ ∞ ∫ − ∞ ∞ e − ( x 2 + y 2 ) / 2 d x d y = ∫ 0 2 π ∫ 0 ∞ r e − r 2 / 2 d r d θ . {\displaystyle I^{2}=\int _{-\infty }^{\infty }\int _{-\infty }^{\infty }e^{-(x^{2}+y^{2})/2}\,dx\,dy=\int _{0}^{2\pi }\int _{0}^{\infty }re^{-r^{2}/2}\,dr\,d\theta .}
The transformation to polar coordinates makes evident that θ is uniformly distributed (constant density) from 0 to 2π, and that the radial distance r has density
r e − r 2 / 2 . {\displaystyle re^{-r^{2}/2}.\,}
… excerpt ends here. Continue reading the full article.
