precision of rnorm
On Thu, 15 Dec 2005, Thomas Lumley wrote:
On Thu, 15 Dec 2005, Phineas wrote:
How many distinct values can rnorm return?
2^32-1. This is described in help(Random)
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.
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.
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.
And the default method for rnorm does so.
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.
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.
I don't get this at all. What technique are you comparing to the bootstrap and for what purpose? -thomas
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
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