[R] set.seed() and .Random.number

Gad Abraham g.abraham at ms.unimelb.edu.au
Thu Oct 26 02:23:47 CEST 2006


Taka Matzmoto wrote:
> Hi R-users
> I have two conditions. For each condition, 100 sets of 10 random numbers 
> from N(0,1) need to be generated.  Here is my question.
> 
> At the begining I specify a seed number. I want to make the 100th set of the 
> first condition and 1st set of the second conditon the same. What do I need 
> to do ?
> 
> After generating 99th set of 10 random numbers and then saving .Random.seed 
> then using .Random.seed for generating 100th set of the first condition and 
> 1st set of the second condtion. Is this right?

Yes, that's right.

> 
> .Random.seed is a vector with 626 numbers, but set.seed() only accepts a 
> integer number.
> What do I need to do for saving .Random.seed and using the saved 
> .Random.seed for setting set.seed() ?

As Prof Ripley pointed to me in a post a while ago out, the help 
?.Random.seed specifies that .Random.seed is the PRNG state, not the 
seed itself. So assign .Random.seed to a variable, and then assign the 
variable to it later:

 > runif(3)
[1] 0.919502 0.361622 0.847657
 > r <- .Random.seed
 > runif(3)
[1] 0.3898361 0.4727398 0.5698874
 > .Random.seed <- r
 > runif(3)
[1] 0.3898361 0.4727398 0.5698874


Cheers,
Gad


-- 
Gad Abraham
Department of Mathematics and Statistics
The University of Melbourne
Parkville 3010, Victoria, Australia
email: g.abraham at ms.unimelb.edu.au
web: http://www.ms.unimelb.edu.au/~gabraham



More information about the R-help mailing list