[R] R random number generator

Prof Brian D Ripley ripley at stats.ox.ac.uk
Thu Apr 29 09:05:46 CEST 1999


On Wed, 28 Apr 1999, Mai Zhou wrote:

> R 0.64 on windows NT 4.0

Um: there is no such version. R 0.64.0?

> Sometimes I got an error message by doing this
> 
> > .Random.seed <- c(1, 1:2)
> > .Random.seed
> [1] 1 1 2
> > runif(5)
> Warning: Wrong length .Random.seed; forgot initial RNGkind? set to Wichmann-Hill[1] 0.02253721 0.84832584  ........

That is a logical error. Because Martin M put backwards compatibility code
in, all initial .Random.seed of length 3 are taken to be mistakes for the
earlier specification of the Wichmann-Hill generator. Although the 
help page does not say so, both "Marsaglia-Multicarry" and "Super-Duper"
need seeds of length 3.  However, this does not apply if you have
already successfully set the RNG kind. So the work-around is

> RNGkind("Marsaglia-Multicarry")  # or .Random.seed <- 1
> .Random.seed <- c(1, 1:2)
> runif(5)
[1] 0.5641106 0.2932388 0.6696743 0.9174765 0.1490988

The rest of the examples I think come in the same way: it depends
on what has been set before. I'll look into it, but I don't think
anyone anticipated that one would swap generators during a session.

[Martin: I am about to commit some fixes.]

-- 
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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list