[R] Same initial seed

diegol diegol81 at gmail.com
Mon Jun 29 00:20:15 CEST 2009


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-tp24246135p24246135.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list