Skip to content

Normal deviate generation - Marsaglia's ziggurat method

3 messages · Ravi Varadhan, Brian Ripley, Roger D. Peng

#
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.
#
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:

            

  
    
#
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: