Box-Muller Transformation

Author

Eric W. Weisstein
February 25, 2004

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Statistics/Box-MullerTransformation.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/Box-MullerTransformation.html.

©2005 Wolfram Research, Inc. except for portions noted otherwise

Solving for (Subscript[x, 1])and (Subscript[x, 2])

FullSimplify[Solve[
{
z1==Sqrt[-2Log[x1]]Cos[2π x2],
z2==Sqrt[-2Log[x1]]Sin[2π x2]
},{x1,x2}]]

Determinant

FullSimplify[Det[Outer[D[#1,#2]&,{Exp[-(z1^2+z2^2)/2],ArcTan[z2/z1]/(2π)},{z1,z2}]]]

Numerical

data=Transpose[Function[{x1,x2},Sqrt[-2Log[x1]]Through[{Cos,Sin}[2π x2]]]@@@Table[Random[],{10^6},{2}]];//Timing

Variance/@data

Mean/@data

<<Graphics`Graphics`

Show[GraphicsArray[
Block[{$DisplayFunction=Identity},Histogram[#,HistogramCategories->100]&/@data]
]]