to start with same seed: set.seed(12345)
:-) On Thu, May 21, 2009 at 1:22 AM, Daniel Nordlund <djnordl...@verizon.net>wrote: > > -----Original Message----- > > From: r-help-boun...@r-project.org > > [mailto:r-help-boun...@r-project.org] On Behalf Of Peter Alspach > > Sent: Wednesday, May 20, 2009 10:02 PM > > To: milton ruser; Chloe Smith > > Cc: r-help@r-project.org > > Subject: Re: [R] Problems with sample variance > > > > Thanks Milton - I misread Chloe's original question. > > > > nSims <- 1000 > > sampSiz <- 15 > > myVars <- tapply(rnorm(nSims*sampSiz), rep(1:nSims, sampSiz), var) > > > > This is a little more succinct, although I do not know enough about > > random number generation to be certain about the effect of breaking a > > single call to rnorm into 1000 bits, rather than having 1000 calls to > > rnorm (or even if there is such an effect. Comment anyone?). > > It doesn't matter whether you use a single call or multiple calls, the same > set of numbers will be generated either way (if one starts with the same > seed). > > > > > It used to be (and I imagine still is) not efficient > > incrementally grow > > an object in a loop [as is done in your code with variance.list <- > > c(variance.list, var(mysample))]. Better to create > > variance.list at its > > full size first (filled with NA) and then populate it. Not that it is > > likely to make too much difference with these numbers. > > > > HTH ..... > > > > Peter Alspach > > Hope this is helpful, > > Dan > > Daniel Nordlund > Bothell, WA USA > > ______________________________________________ > 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<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.