Prof Brian Ripley wrote:
On Tue, 19 Aug 2008, [EMAIL PROTECTED] wrote:

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

Or people were busy: I was away teaching a course, for example.

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:

A better description would certainly have helped! You can look at .Random.seed to see what is happening.

I think what you are observing is that if .Random.seed has not used in the session, any restored value is not used to set the default kind in set.seed. I don't think that is unreasonable (in particular as you can set the kind in set.seed() and I take the notes on ?RNG to suggest that), but would be easy to change/document.

My interpretation of what looking at .Random.seed shows is that set.seed() ignores the RNG {\bf state} that is contained in the restored .Random.seed (until after the first random number has been generated). ?RNG starts with ".Random.seed is an integer vector, containing the random number generator (RNG) state for random number generation in R. It can be saved and restored, ...".

I feel it is a bit of a stretch to claim that "If it is NULL, *return* the currently used RNG." suggests "if it is NULL, and .Random.seed has not been used in the session, ignore the information contained in .Random.seed and *set* the default RNG".

However, knowing what does happen, I acknowledge that the documentation of set.seed() is not inconsistent, but I can't accept that the description of .Random.seed would lead one to anticipate what does happen.

Regards,
Ray Brownrigg

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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel



______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to