From tibshirani at gmail.com  Tue May  2 18:44:25 2006
From: tibshirani at gmail.com (Tibshirani)
Date: Tue, 02 May 2006 12:44:25 -0400
Subject: [Rd] normal random number generator in R
Message-ID: <200605021244.26160.tibshirani@gmail.com>

Hi,

I am trying to figure out how normal random number generator works in R. As I 
look at .../src/nmath/snorm.c file, I find the default algorithm is inverse 
CDF method. In more detail, instead of directly using uniform value by 
unif_rand(), snorm function will first get a sum by adding unif_rand() and 
2^27*unif_rand(), then divide it by 2^27 and transfer it to qnorm5() function 
for inverting. Only a short comment for this operation is available in the 
source:
/* unif_rand() alone is not of high enough precision */

Just curious why this operation is needed? Is it a general algorithm for 
inverse CDF method, or simply unif_rand() in R returns float precision?

Thanks
Tib



[Rd] normal random number generator in R
Tibshirani