Re: [R] random number generator: same seed used in different sessions

From: Jason Liao <jg_liao_at_yahoo.com>
Date: Thu 16 Jun 2005 - 02:39:52 EST


Thank you, Prof. Ripley. Yes, it turned out that different R sessions (batch mode) loaded the same work space. Inserting rm(list=ls(all=TRUE))
on top of the code solves the problem.

> On Wed, 15 Jun 2005, Jason Liao wrote:
>
> > I did several simulation sessions and the result turned out to be a
> > surprise. After some investigation, I found that different R
> sessions
> > of the program used the same seed. Simply, in R210, if I start R
> and
> > type rnorm(1), I always get the same random number. This is
> > contradictary to what is in the R document
> >
> > 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.
>
> That is not a contradiction! Did you ensure that this really was
> `initially', so there is no saved workspace, no .Rprofile etc?
> See if starting with R --vanilla makes a difference.
>
> > I just installed the development version R220. Different sessions
> of R
> > do use different seeds as expected.
>
> There are no R versions R210 or R220: please do read the posting
> guide
> as we ask:
>
> > PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
> --
> Brian D. Ripley, ripley@stats.ox.ac.uk
> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel: +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UK Fax: +44 1865 272595
>

Jason Liao, http://www.geocities.com/jg_liao Dept. of Biostatistics, http://www2.umdnj.edu/bmtrxweb University of Medicine and Dentistry of New Jersey

683 Hoes Lane West, Piscataway‚ NJ 08854
phone 732-235-5429, School of Public Health office
phone 732-235-9824, Cancer Institute of New Jersey office

______________________________________________
R-help@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 Received on Thu Jun 16 02:53:00 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:42 EST