The following notes are taken from the R documentation help files (R version 2.9.2). The information outlines several types of random number generators and includes many references to related material.
## Random Number Generation## Description
## Usage.Random.seed <- c(rng.kind, n1, n2, ...) save.seed <- .Random.seed RNGkind(kind = NULL, normal.kind = NULL) RNGversion(vstr) set.seed(seed, kind = NULL, normal.kind = NULL) ## Arguments
## DetailsThe currently available RNG kinds are given below. `"Wichmann-Hill"` - The seed,
`.Random.seed[-1] == r[1:3]` is an integer vector of length 3, where each`r[i]` is in`1:(p[i] - 1)` , where`p` is the length 3 vector of primes,`p = (30269, 30307, 30323)` . The Wichmann–Hill generator has a cycle length of*6.9536e12*(=`prod(p-1)/4` , see*Applied Statistics*(1984)**33**, 123 which corrects the original article). `"Marsaglia-Multicarry"` :- A
*multiply-with-carry*RNG is used, as recommended by George Marsaglia in his post to the mailing list ‘sci.stat.math’. It has a period of more than*2^60*and has passed all tests (according to Marsaglia). The seed is two integers (all values allowed). `"Super-Duper"` :- Marsaglia's famous Super-Duper from the 70's. This is the original version which does
*not*pass the MTUPLE test of the Diehard battery. It has a period of*about 4.6*10^18*for most initial seeds. The seed is two integers (all values allowed for the first seed: the second must be odd).We use the implementation by Reeds et al. (1982–84). The two seeds are the Tausworthe and congruence long integers, respectively. A one-to-one mapping to S's `.Random.seed[1:12]` is possible but we will not publish one, not least as this generator is**not**exactly the same as that in recent versions of S-PLUS. `"Mersenne-Twister":` - From Matsumoto and Nishimura (1998). A twisted GFSR with period
*2^19937 - 1*and equidistribution in 623 consecutive dimensions (over the whole period). The ‘seed’ is a 624-dimensional set of 32-bit integers plus a current position in that set. `"Knuth-TAOCP-2002":` - A 32-bit integer GFSR using lagged Fibonacci sequences with subtraction. That is, the recurrence used is
*X[j] = (X[j-100] - X[j-37]) mod 2^30*and the ‘seed’ is the set of the 100 last numbers (actually recorded as 101 numbers, the last being a cyclic shift of the buffer). The period is around *2^129*. `"Knuth-TAOCP":` - An earlier version from Knuth (1997).
The 2002 version was not backwards compatible with the earlier version: the initialization of the GFSR from the seed was altered. **R**did not allow you to choose consecutive seeds, the reported ‘weakness’, and already scrambled the seeds.Initialization of this generator is done in interpreted **R**code and so takes a short but noticeable time. `"user-supplied":` - Use a user-supplied generator. See
`Random.user` for details.
The use of ## Value
## NoteInitially, there is no seed; a new one is created from the current time when one is required. Hence, different sessions started at (sufficiently) different times will give different simulation results, by default. However, the seed might be restored from a previous session if a previously saved workspace is restored.
The object Do not rely on randomness of low-order bits from RNGs. Most of the supplied uniform generators return 32-bit integer values that are converted to doubles, so they take at most ## Author(s)of RNGkind: Martin Maechler. Current implementation, B. D. Ripley ## ReferencesAhrens, J. H. and Dieter, U. (1973) Extensions of Forsythe's method for random sampling from the normal distribution. Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) Box, G. E. P. and Muller, M. E. (1958) A note on the generation of normal random deviates. De Matteis, A. and Pagnutti, S. (1993) Kinderman, A. J. and Ramage, J. G. (1976) Computer generation of normal random variables. Knuth, D. E. (1997) Knuth, D. E. (2002) Marsaglia, G. (1997) Marsaglia, G. and Zaman, A. (1994) Some portable very-long-period random number generators. Matsumoto, M. and Nishimura, T. (1998) Mersenne Twister: A 623-dimensionally equidistributed uniform pseudo-random number generator, Reeds, J., Hubert, S. and Abrahams, M. (1982–4) C implementation of SuperDuper, University of California at Berkeley. (Personal communication from Jim Reeds to Ross Ihaka.) Wichmann, B. A. and Hill, I. D. (1982) |

statrefs home > Main > Fundamentals > Sampling and Randomization > Random Number Generators >