Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Box–Muller transform
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Contrasting the two forms== The polar method differs from the basic method in that it is a type of [[rejection sampling]]. It discards some generated random numbers, but can be faster than the basic method because it is simpler to compute (provided that the random number generator is relatively fast) and is more numerically robust.<ref name="Carter">[ftp://ftp.taygeta.com/pub/publications/randnum.tar.Z Everett F. Carter, Jr., ''The Generation and Application of Random Numbers'', Forth Dimensions (1994), Vol. 16, No. 1 & 2.]</ref> Avoiding the use of expensive trigonometric functions improves speed over the basic form.<ref name=Bell68/> It discards {{math|1 − {{pi}}/4 ≈ 21.46%}} of the total input uniformly distributed random number pairs generated, i.e. discards {{math|4/{{pi}} − 1 ≈ 27.32%}} uniformly distributed random number pairs per [[normal distribution|Gaussian]] random number pair generated, requiring {{math|4/{{pi}} ≈ 1.2732}} input random numbers per output random number. The basic form requires two multiplications, 1/2 logarithm, 1/2 square root, and one trigonometric function for each normal variate.<ref>The evaluation of 2{{pi}}''U''<sub>1</sub> is counted as one multiplication because the value of 2{{pi}} can be computed in advance and used repeatedly.</ref> On some processors, the cosine and sine of the same argument can be calculated in parallel using a single instruction. Notably for Intel-based machines, one can use the fsincos assembler instruction or the expi instruction (usually available from C as an [[intrinsic function]]), to calculate complex <math display="block">\exp(iz) = e^{i z} = \cos z + i \sin z, \, </math> and just separate the real and imaginary parts. '''Note:''' To explicitly calculate the complex-polar form use the following substitutions in the general form, Let <math display="inline"> r = \sqrt{- \ln(u_1)} </math> and <math display="inline"> z = 2 \pi u_2. </math> Then <math display="block"> re^{i z} = \sqrt{- \ln(u_1)} e^{i 2 \pi u_2} =\sqrt{-2 \ln(u_1)}\left[ \cos(2 \pi u_2) + i \sin(2 \pi u_2)\right].</math> The polar form requires 3/2 multiplications, 1/2 logarithm, 1/2 square root, and 1/2 division for each normal variate. The effect is to replace one multiplication and one trigonometric function with a single division and a conditional loop.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)