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:

    Are you being sinister or is this some form of practical joke?
    I’m trying to come to the point.
    I refuse to give up my obsession.
    America stop pushing I know what I’m doing.
    America the plum blossoms are falling.
    Allen Ginsberg (b. 1926)