[R] Can simulation involving random number generation be segmented?

Dr L. Y Hin lyhin at netvigator.com
Wed May 25 13:09:00 CEST 2005

Dear all,
Apologies for this pedantic question that only arise when there is hardware
Setting: R 2.1.0 for windows xp sp2.
To generate 1000 samples using rnorm for a simulation activity.
The simulation activity requires so much memory resources that generating
200 samples
clogs up the PF usage as indicated in the Windows Task Manager.
Therefore, short of implementing the simulation on a computer with more
the alternative is to generate the 1000 samples in 5 separate runs,
each generating 200 samples, closing the R window and re-opening between
Question to be addressed:
To maintain consistency and ensure reproducibility of the simulation
results, the 1000 samples
generated in one single run should be indentical to the 5x200 samples
generated on 5 separate
While such consistency can be ensured using set.seed()  in the case of one
single run, in the case
where 5 separate runs are performed, can we do the following to ensure
identical samples being
1. In the first run, specify the seed by, say, set.seed(1)

2. At the end of the first run, store the .Random.seed by the following

3. At the beginning of the second run, assign the saved.seed.1 to
.Random.seed as follows:

4. At the end of the first run, store the new .Random.seed by the following

5. At the beginning of the second run, assign the saved.seed.2 to
.Random.seed as follows:

This is repeated until 5 runs are completed.

Will the paths of random number generation be identical in these two
approaches? If not, is there
a way to ensure this?

Apologies again for this long-winded inquiry.

Thank you.

More information about the R-help mailing list