[Rd] Random seed not reset when starting R (PR#11089)
pmelsted at gmail.com
pmelsted at gmail.com
Sat Apr 5 06:10:03 CEST 2008
Full_Name: Pall Melsted
Version: 2.3.1
OS: WinXP
Submission from: (NULL) (71.240.25.175)
Random set is not reset when starting R again. When R starts with a
[Previously saved workspace restored]
it seems that the .Random.seed variable is already set. If you quit R (and don't
save your workspace) the next time you start R .Random.seed will be set to the
same value again.
Steps to reproduce:
1. Start R afresh and type runif(1)
2. Quit R and do not save workspace
3. Start R again (make sure a previous workspace was restored) type runif(1)
again, this will be the same "random" number as before.
>From documentation on .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.
"
This behavior is very counterintuitive and can mess up simulation results,
especially when sampling. The seed really should be set when R starts,
regardless of whether .Random.seed is set.
This bug has also been reproduced on MacOSX 10.4, R version 2.2.1
More information about the R-devel
mailing list