Skip to content

precision of rnorm

3 messages · Phineas Campbell, Thomas Lumley, Brian Ripley

#
How many distinct values can rnorm return?

I assume that rnorm manipulates runif in some way, runif uses the Mersenne
Twister, which has a period of 2^19937 - 1.  Given that runif returns a 64
bit precision floating point number in [0,1], the actual period of the
Mersenne Twister in a finite precision world must be significantly less.

One of the arguments for Monte Carlo over the bootstrap is that for a sample
size n the bootstrap can return at most 2^n distinct resamples, however for
even for relatively small sample sizes there may be no increase in precision
in using Monte Carlo.



Phineas Campbell
#
On Thu, 15 Dec 2005, Phineas wrote:

            
2^32-1.  This is described in help(Random)
No. Not at all.  Consider a sequence of 1-bit numbers: individual values 
will repeat fairly frequently but the sequence need not be periodic with 
any period
1101001000100001000001
is the start of one fairly obvious non-periodic sequence.

There are reasons that a longer period than 2^32 is useful.  The most 
obvious is that you can construct higher-resolution numbers from several 
runif()s.  The Mersenne Twister was designed so that quite long 
subsequences (623 elements) would be uniformly distributed.

Less obvious is that fact that a periodic pseudorandom sequence is likely 
to show a frequency distribution of repeat values that differs from the 
random sequence once you get beyond about the square root of the period. 
This means that a 32-bit PRNG should really have a period of at least 
2^64.

The randaes package provides a runif() that uses 64 bits to construct a 
double, providing about 53 bits of randomness.
I don't get this at all. What technique are you comparing to the bootstrap 
and for what purpose?

 	-thomas
#
On Thu, 15 Dec 2005, Thomas Lumley wrote:

            
Mot for the default method for rnorm, as it uses two runif's.  The answer 
is somewhere in the 2^50s, as the base uniform random number uses 2^59 but 
some will be mapped to the same result.
And the default method for rnorm does so.