As I understand it, how R âânormallyâ does it is to use the system clock to set the seed once per session, unless you use set.seed() to set a new seed. You chose to set the seed to a different value. But from that point on, the pseudo random number generation continues in the same way it ânormallyâ does. In your code below, each of your 100 histograms will be different. If you then execute the for loop again (but not the set.seed(100) statement), you will get a different set of histograms. The only way you would be âconfined to set.seed(100)â is if you keep resetting the seed to 100.
Dan Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204 From: C W [mailto:tmrs...@gmail.com] Sent: Monday, March 18, 2013 11:50 AM To: Nordlund, Dan (DSHS/RDA) Cc: r-help Subject: Re: [R] How to stop set.seed() besides exiting out of R? set.seed(100) for (i in 1:100){ a <- rnorm(1000, mean=0, sd=1) hist(a) } #Now say, I want to simulate without being confined to set.seed(100), I just want to get a simulation like how R "normally" does it. Mike On Mon, Mar 18, 2013 at 2:40 PM, Nordlund, Dan (DSHS/RDA) <nord...@dshs.wa.gov<mailto:nord...@dshs.wa.gov>> wrote: > -----Original Message----- > From: r-help-boun...@r-project.org<mailto:r-help-boun...@r-project.org> > [mailto:r-help-bounces@r-<mailto:r-help-bounces@r-> > project.org<http://project.org>] On Behalf Of C W > Sent: Monday, March 18, 2013 11:27 AM > To: r-help > Subject: [R] How to stop set.seed() besides exiting out of R? > > Hi list, > > I am curious how to stop the set.seed(), I don't want the same repeated > random number. I know I can set it to a different seed, but I don't > want > to go through the trouble of setting different seed every time. > > Thanks, > Mike > Can you show us how you are using set.seed() that results in getting the same sequence repeatedly? If you are doing simulations in a loop, then set the seed once, outside the loop. Otherwise, I am not sure what you are doing that causes problems. A reproducible example would really help. Dan Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204 ______________________________________________ R-help@r-project.org<mailto:R-help@r-project.org> mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.