zrnorm(n) zrnormLZLLV(n) zrnormMT(n) zrnormV1(n) zrnormVec(x) zrnormVecV1(x) zrnormGSL(n) zrnormQL(n) zrnormGl(n) zrnormR(n) zsetseed(s) zsetseedV1(s) zsetseedLZLLV(s) zsetseedGSL(s) zsetseedQL(s) zsetseedGl(s) zsetseedMT(s) zgetseed() zgetseedV1()
zrnorm*
functions all return a vector of the requested
size.The zsetseed*
functions do not return a value, but set the seed
of the generator.The zgetseed*
functions return the (integer) seed.
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.
The function 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.
The zrnormGSL
functions use the GNU GSL implementation by Jochen Voss.
They too can be recommended for use.
The functions zrnormQL
and zrnormGl
use, respectively,
functions adapted from the GNU Gretl and QuantLib projects. They have
been added primarily for comparison to the other engines.
The function zrnormR
uses the unif_rand
uniform
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.
Website of John Burkardt. http://people.sc.fsu.edu/~jburkardt/
Website of Jochen Voss. http://www.seehuhn.de/pages/ziggurat
set.seed(42)
system.time(replicate(500, rnorm(10000)))
zsetseed(42)
system.time(replicate(500, zrnorm(10000)))
Run the code above in your browser using DataLab