From Ray.Brownrigg at mcs.vuw.ac.nz  Tue Jul  8 00:22:19 2008
From: Ray.Brownrigg at mcs.vuw.ac.nz (Ray Brownrigg)
Date: Tue, 8 Jul 2008 10:22:19 +1200
Subject: [Rd] RNGkind() state
Message-ID: <200807081022.19229.Ray.Brownrigg@mcs.vuw.ac.nz>

This looks like a bug to me, and is a bit hard to describe, but easy to reproduce.  
Basically, if RNGkind is saved as something other than the default, and if the first 
operation in a session is a set.seed(), the default is reverted to.  Reproduce by:

cafe-rozo>  R --vanilla

R version 2.7.1 (2008-06-23)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> sessionInfo()
R version 2.7.1 (2008-06-23)
i386--netbsdelf

locale:
C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base
> set.seed(1); runif(1)		# check the default
[1] 0.2655087
> RNGkind("Mar")
> RNGkind()
[1] "Marsaglia-Multicarry" "Inversion"
> set.seed(1); runif(1)		# now check again
[1] 0.006153224
> set.seed(1)			# save seed and RNGkind
> q("yes")
cafe-rozo>  R

R version 2.7.1 (2008-06-23)
: etc
[Previously saved workspace restored]

> runif(1)		# with a saved seed, Marsaglia-Multicarry is used
[1] 0.006153224
> set.seed(1); runif(1)
[1] 0.006153224
> q()
Save workspace image? [y/n/c]: n
cafe-rozo> 

R version 2.7.1 (2008-06-23)
: etc
[Previously saved workspace restored]

> set.seed(1); runif(1)		# saved RNGkind is ignored ...
[1] 0.2655087
> RNGkind()		# and overridden ...
[1] "Mersenne-Twister" "Inversion"
> q("no")
cafe-rozo>  R

R version 2.7.1 (2008-06-23)
: etc
[Previously saved workspace restored]

> RNGkind()		# and wrongly reported!
[1] "Mersenne-Twister" "Inversion"
> runif(1)			# Note this is actually using Marsaglia-Multicarry
[1] 0.006153224
>

Ray Brownrigg
Mathematics, Statistics and Computer Science
Victoria University of Wellington
Wellington, NZ



[Rd] RNGkind() state
Ray Brownrigg