Last data update: 2014.03.03
R: The Ziggurat normal and exponential generator
The Ziggurat normal and exponential generator
Description
Generates normal and exponential random pseudo-random numbers by the method of Marsaglia and Tsang.
Usage
rziggurat(n, normal=TRUE, new.start=FALSE, seed=556677)
Arguments
n
number of values to generate. If n is a vector, length(n) values will be generated
normal
logical scalar; if TRUE normal values are produced, otherwise exponential values
new.start
logical scalar. If TRUE the generator will be started afresh using the seed
seed
scalar 32 bit starting integer
Value
Generates a vector of real pseudo random numbers.
Note
This function does not work properly on LP64 machines which use 64 bit
longs.
This implementation running in R is approximately three times as fast as rnorm().
Author(s)
Bob Wheeler bwheelerg@gmail.com
References
Marsaglia, George, and Tsang, Wai Wan. 2000. The Ziggurat method for generating random variables. Journal of Statistical software. 5-8. http://www.jstatsoft.org/v05/i08/
Examples
rziggurat(50,new.start=TRUE)
rziggurat(50)
rziggurat(50,new.start=TRUE)
Results