Hi All. (This is probably an incredibly stupid question :)) I have just noticed that every time I start an R2.3 session and request a random number (say with rnorm) that I receive the same number. AFAIK I have not set a seed at any point. Returning to an older version of R(v1.8) I get the behaviour that I have come to expect, where a new seed is automatically generated for each new session (actually it was a student running bootstraps on multiple machines that has noticed this). I am running R2.3 for windows on winXP pro, AMD Athlon 2400+. Thanks in advance and be gentle. C <...retreats and waits for imminent admonishment...> -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Dr. Carl Donovan Research Fellow in Statistical Computing Ph +44 1334 461802 The Observatory Buchanan Gardens University of St Andrews St Andrews Fife KY16 9LZ Scotland
On 6/1/2006 3:13 PM, Carl wrote:> Hi All. > (This is probably an incredibly stupid question :)) > > I have just noticed that every time I start an R2.3 session and request > a random number (say with rnorm) that I receive the same number. AFAIK I > have not set a seed at any point. Returning to an older version of > R(v1.8) I get the behaviour that I have come to expect, where a new seed > is automatically generated for each new session (actually it was a > student running bootstraps on multiple machines that has noticed this). > > I am running R2.3 for windows on winXP pro, AMD Athlon 2400+.R saves the random seed in a variable called .Random.seed. (Because of the initial dot, this is not normally shown by ls(). Use ls(all=T) to see it. If you save this to an .RData file, it will be reloaded next time you run, and your RNG will continue on from before. I'm guessing you saved a copy once, but are *not* saving your workspace each time you restart: hence you get the same seed each time. You can avoid this by deleting the saved workspace, or just deleting .Random.seed and saving it (but it will be resurrected next time you do a save), or by always saving your workspace (so you save a different seed every time). My advice would be not to save the workspace; I save individual objects sometimes, but I like a nice clean workspace each time I start. Duncan Murdoch
according to ?.Random.seed, `Note' section, different R sessions give differen simulation results; maybe each time you start R you load a previously saved workspace, with an existing .Random.seed, i.e., check if the .Random.seed value is the same each time you start R. I hope it helps. Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm Quoting Carl <carl at mcs.st-and.ac.uk>:> Hi All. > (This is probably an incredibly stupid question :)) > > I have just noticed that every time I start an R2.3 session and > request > a random number (say with rnorm) that I receive the same number. > AFAIK I > have not set a seed at any point. Returning to an older version of > R(v1.8) I get the behaviour that I have come to expect, where a new > seed > is automatically generated for each new session (actually it was a > student running bootstraps on multiple machines that has noticed > this). > > I am running R2.3 for windows on winXP pro, AMD Athlon 2400+. > > Thanks in advance and be gentle. > C > > <...retreats and waits for imminent admonishment...> > > -- > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Dr. Carl Donovan > Research Fellow in Statistical Computing > Ph +44 1334 461802 > The Observatory > Buchanan Gardens > University of St Andrews > St Andrews > Fife > KY16 9LZ > Scotland > > ______________________________________________ > 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 > >Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
That certainly sounds like the behaviour you would get if you had a .Random.seed in your work space. If you do not save your workspace at the end of the session then the random seed will be in exactly the same state every time you start a new R session, and you will get identical simulations from the same sequence of function calls. So you either need to save your work space or launch R from the command line with --no-restore or --vanilla and get a fresh starting seed in each session based on the time stamp. Have you tried checking for the existence of .Random.seed before you call any random number functions (e.g. with objects(all.names=TRUE))? I don't know why you would get different behaviour from R 1.8.0 since the RNG hasn't changed since 1.7.0. Martyn Quoting Carl <carl at mcs.st-and.ac.uk>:> Hi All. > (This is probably an incredibly stupid question :)) > > I have just noticed that every time I start an R2.3 session and request > a random number (say with rnorm) that I receive the same number. AFAIK I > have not set a seed at any point. Returning to an older version of > R(v1.8) I get the behaviour that I have come to expect, where a new seed > is automatically generated for each new session (actually it was a > student running bootstraps on multiple machines that has noticed this). > > I am running R2.3 for windows on winXP pro, AMD Athlon 2400+. > > Thanks in advance and be gentle. > C > > <...retreats and waits for imminent admonishment...> > > -- > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Dr. Carl Donovan > Research Fellow in Statistical Computing > Ph +44 1334 461802 > The Observatory > Buchanan Gardens > University of St Andrews > St Andrews > Fife > KY16 9LZ > Scotland > > ______________________________________________ > 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 >----------------------------------------------------------------------- This message and its attachments are strictly confidential. ...{{dropped}}