From ligges at statistik.tu-dortmund.de  Sat Apr  5 21:32:47 2008
From: ligges at statistik.tu-dortmund.de (Uwe Ligges)
Date: Sat, 05 Apr 2008 21:32:47 +0200
Subject: [Rd] Random seed not reset when starting R (PR#11089)
In-Reply-To: <20080405041003.951012834154@mail.pubhealth.ku.dk>
References: <20080405041003.951012834154@mail.pubhealth.ku.dk>
Message-ID: <47F7D3DF.1050300@statistik.tu-dortmund.de>



pmelsted at gmail.com wrote:
> Full_Name: Pall Melsted
> Version: 2.3.1

So you report a bug on a ancient version of R? Have you read the FAQ 
chapter on reporting bugs?  Please do read the documentation!
Addtionally, this is not a bug at all, but desired and documented behaviour.



> 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.


Yes, as documented. It is stored in object .Random.seed which is in the 
workspace (and saved once you save the workspace).


> 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.

It is set to some more or less "random" value, as documented. If you 
want something fixed, why not use set.seed?

Uwe Ligges




> 
> This bug has also been reproduced on MacOSX 10.4, R version 2.2.1
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] Random seed not reset when starting R (PR#11089)
Uwe Ligges