Hello, I have tried a few searches without luck before posting, since this one seems a pretty basic question. I am using R 2.7.0 on WinXP, as I have long started using this version for my thesis work and am reluctant to update fearing consistency/backward compatibility issues could happen. I noticed that whenever I start an R session (launch the console application) and run a script involving random number generation, eg:> rnorm(10)I get the same result. In fact, each time I start a new R session and enter> .Random.seedI get the same exact vector. From ?.Random.seed: "Initially, there is no seed; a new one is created from the current time when one is required. Hence, different sessions will give different simulation results, by default." (as stated in R 2.7.0's documentation) When I try RSiteSearch(".Random.seed") I get this updated result: "Initially, there is no seed; a new one is created from the current time when one is required. Hence, different sessions started at (sufficiently) different times will give different simulation results, by default. However, the seed might be restored from a previous session if a previously saved workspace is restored." My PC clock is working fine. I think the problem is not related to allotting "sufficient" time between sessions either, which leads me to think this has to do with a previously saved workspace, which in the case I mention is indeed restored. I would like to generate different random numbers in each session. The two choices I seem to have are: i) Not restore the workspace so a new seed is created from the current time (I have to look into how to go about this); ii) Leave the workspace alone and manually set a new seed via set.seed() Am I leaving any options out or getting something wrong? Thank you. ----- ~~~~~~~~~~~~~~~~~~~~~~~~~~ Diego Mazzeo Actuarial Science Student Facultad de Ciencias Econ?micas Universidad de Buenos Aires Buenos Aires, Argentina -- View this message in context: http://www.nabble.com/Same-initial-seed-tp24246135p24246135.html Sent from the R help mailing list archive at Nabble.com.
Update: I had tried, immediately after launching the console:> rm(list=ls())which did not seem to affect .Random.seed. But now I try:> rm(.Random.seed)which seems to force .Random.seed to regenerate from current time. Can I feel confident to have solved the problem? Thanks! diegol wrote:> > Hello, > > I have tried a few searches without luck before posting, since this one > seems a pretty basic question. > I am using R 2.7.0 on WinXP, as I have long started using this version for > my thesis work and am reluctant to update fearing consistency/backward > compatibility issues could happen. > > I noticed that whenever I start an R session (launch the console > application) and run a script involving random number generation, eg: > >> rnorm(10) > > I get the same result. In fact, each time I start a new R session and > enter > >> .Random.seed > > I get the same exact vector. From ?.Random.seed: > > "Initially, there is no seed; a new one is created from the current time > when one is required. Hence, different sessions will give different > simulation results, by default." (as stated in R 2.7.0's documentation) > > When I try RSiteSearch(".Random.seed") I get this updated result: > > "Initially, there is no seed; a new one is created from the current time > when one is required. Hence, different sessions started at (sufficiently) > different times will give different simulation results, by default. > However, the seed might be restored from a previous session if a > previously saved workspace is restored." > > My PC clock is working fine. I think the problem is not related to > allotting "sufficient" time between sessions either, which leads me to > think this has to do with a previously saved workspace, which in the case > I mention is indeed restored. > > I would like to generate different random numbers in each session. The two > choices I seem to have are: > i) Not restore the workspace so a new seed is created from the current > time (I have to look into how to go about this); > ii) Leave the workspace alone and manually set a new seed via set.seed() > > Am I leaving any options out or getting something wrong? > > Thank you. >----- ~~~~~~~~~~~~~~~~~~~~~~~~~~ Diego Mazzeo Actuarial Science Student Facultad de Ciencias Econ?micas Universidad de Buenos Aires Buenos Aires, Argentina -- View this message in context: http://www.nabble.com/Same-initial-seed-tp24246135p24246357.html Sent from the R help mailing list archive at Nabble.com.
diegol wrote:> Hello, > > I have tried a few searches without luck before posting, since this one > seems a pretty basic question. > I am using R 2.7.0 on WinXP, as I have long started using this version for > my thesis work and am reluctant to update fearing consistency/backward > compatibility issues could happen. > > I noticed that whenever I start an R session (launch the console > application) and run a script involving random number generation, eg: > > >> rnorm(10) >> > > I get the same result. In fact, each time I start a new R session and enter > > >> .Random.seed >> > > I get the same exact vector. From ?.Random.seed: > > "Initially, there is no seed; a new one is created from the current time > when one is required. Hence, different sessions will give different > simulation results, by default." (as stated in R 2.7.0's documentation) > > When I try RSiteSearch(".Random.seed") I get this updated result: > > "Initially, there is no seed; a new one is created from the current time > when one is required. Hence, different sessions started at (sufficiently) > different times will give different simulation results, by default. However, > the seed might be restored from a previous session if a previously saved > workspace is restored." > > My PC clock is working fine. I think the problem is not related to allotting > "sufficient" time between sessions either, which leads me to think this has > to do with a previously saved workspace, which in the case I mention is > indeed restored. > > I would like to generate different random numbers in each session. The two > choices I seem to have are: > i) Not restore the workspace so a new seed is created from the current time > (I have to look into how to go about this); >That's the best choice. Why do you want all the leftovers from the previous session? It's better to start with a clean slate.> ii) Leave the workspace alone and manually set a new seed via set.seed() >That's a good idea to make your work reproducible. This is not exclusive of i); do both.> Am I leaving any options out or getting something wrong? >A third choice is to remove .Random.seed, and then the timer will be used to regenerate it. But i) *and* ii) are better ideas. Duncan Murdoch> Thank you. > > ----- > ~~~~~~~~~~~~~~~~~~~~~~~~~~ > Diego Mazzeo > Actuarial Science Student > Facultad de Ciencias Econ?micas > Universidad de Buenos Aires > Buenos Aires, Argentina >