Skip to content
Prev 32673 / 398526 Next

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: