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

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Wed, 20 Aug 2008 09:46:50 +0100 (BST)

On Tue, 19 Aug 2008, Ray.Brownrigg_at_mcs.vuw.ac.nz 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.

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

-- 
Brian D. Ripley,                  ripley_at_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


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

Received on Wed 20 Aug 2008 - 08:50:21 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 Thu 21 Aug 2008 - 17:37:16 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