Huntsinger, Reid
2005-May-25 16:46 UTC
[R] Can simulation involving random number generation be segm ented?
I don't see why you need to shut R down between runs. Can you just replace each time you generate a new 200 samples? You might also find "gc()" helpful if you generate a lot of intermediate objects in a single run. Delete objects you no longer need (unless you're going to replace them and can afford to keep them around), then an explicit request gc() might help keep you under the wire. Reid Huntsinger -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Uwe Ligges Sent: Wednesday, May 25, 2005 8:56 AM To: Dr L. Y Hin Cc: r-help at stat.math.ethz.ch Subject: Re: [R] Can simulation involving random number generation be segmented? Dr L. Y Hin wrote:> Dear all, > Apologies for this pedantic question that only arise when there ishardware> limitation. > Setting: R 2.1.0 for windows xp sp2. > Scenario: > To generate 1000 samples using rnorm for a simulation activity. > Background: > 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 > resources, > the alternative is to generate the 1000 samples in 5 separate runs, > each generating 200 samples, closing the R window and re-opening between > runs. > 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 > runs. > 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 > generated? > 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 > manner: > saved.seed.1<-.Random.seed > > 3. At the beginning of the second run, assign the saved.seed.1 to > .Random.seed as follows: > .Random.seed<-saved.seed.1 > > 4. At the end of the first run, store the new .Random.seed by thefollowing> manner: > saved.seed.2<-.Random.seed > > 5. At the beginning of the second run, assign the saved.seed.2 to > .Random.seed as follows: > .Random.seed<-saved.seed.2 > > This is repeated until 5 runs are completed. > > Will the paths of random number generation be identical in these two > approaches?Yes. Uwe Ligges If not, is there> a way to ensure this? > > Apologies again for this long-winded inquiry. > > Thank you. > Best > Lin > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Maybe Matching Threads
- Trouble with Optimization in "Alabama" Package
- Classification Trees and basic Random Forest pkg using t ree structures in C
- That 'make check-all' problem with the survival package
- Why R simulation gives same random results?
- Rgnome depends on obsolete components libglade/libxml (PR#8248)