[Rd] RNG usability

Prof Brian D Ripley ripley@stats.ox.ac.uk
Wed, 23 Feb 2000 20:20:25 +0000 (GMT)


On Wed, 23 Feb 2000, Paul Gilbert wrote:

> Brian
> 
> I presume that I misunderstand something, but if I do not then I think
> there is a serious problem for the way many people actually use RNGs
> (rather than studying or testing them). To summarize the way I
> understand the documentation and what you have said:
> 
> 1/ Directly setting the .Random.seed is not something that users should
> do and will not in the future be guaranteed to put the RNG into a state
> that would reproduce a sequence of random numbers. Users should use
> set.seed to put the RNG in a known state. (BTW, I was using my syskern
> library version of set.seed before, which just set .Random.seed. Sorry
> about the confusion.)

It is guaranteed to reproduce it, but not to be a valid state if it
were never generated.  So replace `known' by `valid'.

> 2/ set.seed takes only a single integer as an argument, so there is no
> guaranteed way to query the state of the RNG at any given time, and then
> reset it to that state at a later time.

Yes, there is an almost guaranteed way, but only if you restore a previous
value of .Random.seed. The problem is that for complicated generators it is
almost impossible to check if the supplied value is a reasonable one,
so we don't.

The exceptions are non-stateless variate generators, and the Box-Muller one
is such and has a warning to that effect, now:

Note:

     `.Random.seed' saves the seed set for the uniform random-number
     generator, at least for the system generators. It does not
     necessarily save the state of other generators, and in particular
     does not save the state of the Box-Muller normal generator. If you
     want to reproduce work later, call `set.seed' rather than set
     `.Random.seed'.

Incidentally, changes to both rpois and rbinom mean that you may get
different numbers of uniforms drawn and hence different results in the
future. That's life, I am afraid.

Brian

-- 
Brian D. Ripley,                  ripley@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-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._