This package regroups and provides a nummber of implementations of the Ziggurat generator for drawing (standard) normally distributed random numbers. Ziggurat was introduced by Marsaglia and Tsang (JSS, 2000) and improved by Leong, Zhang, et al (JSS, 2005).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
An integer determining the length of the returned N(0,1) vector.
A numeric vector, already allocated, that is to filled with N(0,1) draws.
An integer number used to seed the Ziggurat algorithm.
An numeric vector of length four with the state parameters.
The ‘MT’ variants provide the original Marsaglia and Tsang implementation, updated to work in 32 and 64 bit environments. Their use is not recommended.
The ‘LZLLV’ variants provide the updated Marsaglia and Tsang implementation, based on the comment by Leong, Zhang, Luk, Lee and Villasenor. These versions should be suitable. The code has also been updated to work in 32 and 64 bit environments.
The ‘V1’ variants are based on an earlier implementation by John Burkardt. While fastest, they also correspond to just the Marsaglia and Zhang approach and should not be used.
zrnorm() (and corresponding seed setter
zsetseed() and getter
zgetseed()) is the recommended
implementation based on merging John Burkardt earlier code with the
Leong et al improvements.
zrnormGSL functions use the GNU GSL implementation by Jochen Voss.
They too can be recommended for use.
zrnormGl use, respectively,
functions adapted from the GNU Gretl and QuantLib projects. They have
been added primarily for comparison to the other engines.
zrnormR uses the
generator from R (which defaults to the Mersenne Twister). It is
useful when the Zigurrat generator is used as a user-supplied
generator in R. However, it stores state in R's internal structures
which makes it a little slower than other alternatives available here.
zrnorm* functions all return a vector of the requested
zsetseed* functions do not return a value, but set the seed
of the generator.
zgetseed* functions return the (integer) seed. This is
actually not sufficient to capture the state, so
zsetpars provide this functionality with a vector of size four.
Use these functions with caution.
George Marsaglia and Wai Wan Tsang. The Ziggurat Method for Generating Random Variables. Journal of Statistical Software, Vol 5, Iss 8, Oct 2000 https://www.jstatsoft.org/v05/i08
Philip H W Leong, Ganglie Zhang, Dong-U Lee, Wayne Luk, and John Villasenor. A Comment on the Implementation of the Ziggurat method, Journal of Statistical Software, Vol 12, Iss 7, Feb 2005 https://www.jstatsoft.org/v12/i07
Website of John Burkardt. https://people.sc.fsu.edu/~jburkardt/
Website of Jochen Voss. https://www.seehuhn.de/pages/ziggurat
1 2 3 4 5
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.