Ravi Varadhan
2003-May-30 14:21 UTC
[R] Normal deviate generation - Marsaglia's ziggurat method
Hi: I was wondering why Marsaglia's new ziggurat method for generating deviates from the standard normal distribution has not been implemented in the R base package. I know that it is available in SuppDists pacakage of Bob Wheeler, as "rziggurat". According my timing tests, it is about 6 to 7 times faster (on a Pentium 2.4 MHz) machine than the default Inversion method used in R base package. thanks, Ravi.
Prof Brian Ripley
2003-May-30 14:53 UTC
[R] Normal deviate generation - Marsaglia's ziggurat method
Accuracy and reliability are more important than speed. As you say, it is available elsewhere, but who actually needs a faster method? 1 million normals take 0.55s on my machine (an Athlon 2600): 1 million uniforms take 0.16s, so there is not I think scope to be `6 to 7 times faster' at R level. rziggurat takes 0.51s on the same machine, despite saying This implementation running in R is approximately three times as fast as rnorm(). So I checked some other machines runif rnorm rziggurat 2.4Ghz P4 0.33 1.30 0.37 1GHz PIII 0.40 1.47 0.94 Athlon 2600 0.16 0.55 0.51 There's something rather strange about the P4 results relative to the others, possibly due to cache sizes. (Linux RH7.3 for the first two, RH8.0 for the last, and the same compiled code running on each.) My point remains: who wants 1 million random uniforms and wants to save fractions of a second? Also, I was wondering why some people expect R to provide exactly what they fancy, free of charge? On Fri, 30 May 2003, Ravi Varadhan wrote:> I was wondering why Marsaglia's new ziggurat method for generating > deviates from the standard normal distribution has not been implemented > in the R base package. I know that it is available in SuppDists > pacakage of Bob Wheeler, as "rziggurat". According my timing tests, it > is about 6 to 7 times faster (on a Pentium 2.4 MHz) machine than the > default Inversion method used in R base package.-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Roger D. Peng
2003-May-30 17:16 UTC
[R] Normal deviate generation - Marsaglia's ziggurat method
Since it is available in the `SuppDists' package, why do we need it in the `base' package? There are perhaps hundreds of useful functions that exist in external packages that are not in `base'. My understanding was that one goal was to keep `base' from getting too bloated. -roger Ravi Varadhan wrote:> Hi: > > I was wondering why Marsaglia's new ziggurat method for generating > deviates from the standard normal distribution has not been implemented > in the R base package. I know that it is available in SuppDists > pacakage of Bob Wheeler, as "rziggurat". According my timing tests, it > is about 6 to 7 times faster (on a Pentium 2.4 MHz) machine than the > default Inversion method used in R base package. > > thanks, > Ravi. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > >