Marsaglia Polar Method - Practical Considerations

Practical Considerations

A direct application of this idea,

is called the Box Muller transform, in which the chi variate is usually generated as

but that transform requires logarithm, square root, sine and cosine functions. 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 fsincos assembler instruction or the expi instruction (available i.e. in D), to calculate complex

and just separate the real and imaginary parts.

The polar method, in which a random point (x, y) inside the unit circle is projected onto the unit circumference by setting s = x2 + y2 and forming the point

is a faster procedure. Some researchers argue that the conditional if instruction (for rejecting a point outside of the unit circle), can make programs slower on modern processors equipped with pipelining and branch prediction. Also this procedure requires about 27% more evaluations of the underlying random number generator (only of generated points lie inside of unit circle).

That random point on the circumference is then radially projected the required random distance by means of

using the same s because that s is independent of the random point on the circumference and is itself uniformly distributed from 0 to 1.

Read more about this topic:  Marsaglia Polar Method

Famous quotes containing the word practical:

    Great statesmen seem to direct and rule by a sort of power to put themselves in the place of the nation over which they are set, and may thus be said to possess the souls of poets at the same time they display the coarser sense and the more vulgar sagacity of practical men of business.
    Woodrow Wilson (1856–1924)