The Ziggurat Method for Generating Random Variables
We provide a new version of our ziggurat method for generating a random variable from a given decreasing density. It is faster and simpler than the original, and will produce, for example, normal or exponential variates at the rate of 15 million per second with a C version on a 400MHz PC. It uses two tables, integers k_i, and reals w_i. Some 99% of the time, the required x is produced by: Generate a random 32-bit integer j and let i be the index formed from the rightmost 8 bits of j. If j < k, return x = j x w_i. We illustrate with C code that provides for inline generation of both normal and exponential variables, with a short procedure for settting up the necessary tables.
Year of publication: |
2000-10-02
|
---|---|
Authors: | Marsaglia, George ; Tsang, Wai Wan |
Published in: |
Journal of Statistical Software. - American Statistical Association. - Vol. 05.2000, i08
|
Publisher: |
American Statistical Association |
Saved in:
Saved in favorites
Similar items by person
-
Fast Generation of Discrete Random Variables
Marsaglia, George, (2004)
-
Some Difficult-to-pass Tests of Randomness
Marsaglia, George, (2002)
-
The Monty Python Method for Generating Gamma Variables
Marsaglia, George, (1999)
- More ...