[R] How to obtain seed after generating random number?

Ben Bolker bbolker at gmail.com
Tue Aug 24 20:56:06 CEST 2010

> On Aug 24, 2010, at 10:11 AM, Bogaso Christofer wrote:
> Dear all, I was doing an experiment to disprove some theory therefore
> performing lot of random simulation. Goal is to show the audience that
> although something has very rare chance to occur but it doesn't mean that
> event would be impossible.
> In short, I need to know the seed ***after*** generating the random numbers.

  Does ?.Random.seed help?

  It doesn't let you "go back and get the random seed that this sequence
was started from", though.  So you may need to checkpoint reasonably frequently
by saving .Random.seed ...

  Another alternative is to use set.seed() at the same
checkpointing intervals (e.g. a different sequential
value for each in a series of simulations) -- that might run the risk
of a slightly higher correlation between successive simulations (I'm not sure
what can be guaranteed about the properties of sequences from neighboring seeds)

More information about the R-help mailing list