[R] Initialising Mersenne-Twister with one integer

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Sep 25 10:48:16 CEST 2006


On Mon, 25 Sep 2006, Gad Abraham wrote:

> Hi,
>
> It seems to me that the Mersenne-Twister PRNG can be initialised using
> one integer instead of 624 integers, since inside RNG.c code there's a
> function defined as MT_sgenrand(Int32).
>
> How do I actually set this seed within R?

set.seed(), on the help page for ?.Random.seed.

> I've tried:
>
> > .Random.seed <- c(3, 1)
> > runif(1)
> Error in runif(1) : .Random.seed has wrong length

>From the help page

      '.Random.seed' is an integer vector, containing the random number
      generator (RNG) *state* for random number generation in R.  It can
      be saved and restored, but should not be altered by the user.

> In addition, is '3' actually the correct rng.kind for the Mersenne-Twister?
>
> I'm using R version 2.2.1, 2005-12-20 on Ubuntu Dapper Linux 686.

Not current, but I suspect the help page is the same in that version.

-- 
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



More information about the R-help mailing list