[Rd] RNGkind() state (PR#12567)

From: <Ray.Brownrigg_at_mcs.vuw.ac.nz>
Date: Tue, 19 Aug 2008 07:15:09 +0200 (CEST)


I sent this to R-devel early last month, but have received no response, so I guess it really is a bug.

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



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue 19 Aug 2008 - 14:16:30 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 20 Aug 2008 - 11:37:14 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive