From ripley@stats.ox.ac.uk  Tue Feb 22 19:37:03 2000
From: ripley@stats.ox.ac.uk (Prof Brian D Ripley)
Date: Tue, 22 Feb 2000 19:37:03 +0000 (GMT)
Subject: [Rd] reproducing Box-Muller numbers
In-Reply-To: <38B2D4D9.5B4A0C50@bank-banque-canada.ca>
Message-ID: <Pine.GSO.4.05.10002221927490.13440-100000@auk.stats>

On Tue, 22 Feb 2000, Paul Gilbert wrote:

> There seems to be a minor problem with reproducing numbers from rnorm with
> Box-Muller. The pattern suggests it might have something to do with the value
> that gets dropped when an odd number of numbers is requested. (Details below.)

Yes, it is. I wouldn't recommend that generator, but Martin M requested it
(and for .Random.seed to store the normal type).

I'll make a call to set.seed clear the saved value. That's all we intend to
be reproducible, setting the state by set.seed.

> Also, could "user-supplied" be added as an option for normal.kind in RNGkind.
> I'm sure the Box-Muller in R is better than my own attempt, but I would like to
> be able to reproduce results I've obtained in the past.

Not very easily, and we are in feature freeze for 1.0.0 now, so not before
1.1.0. It would be easy to patch in your own version, but the 
difficulty is to add all the protection needed for user-supplied code.

> Paul Gilbert
> ________
> 
> > .Random.seed <- c(200,979,1479,1542)
> > rnorm(5)
> [1] -1.9242522 -0.8956891  2.1221336  0.8166920 -0.1356919
> > .Random.seed <- c(200,979,1479,1542)
> > rnorm(5)
> [1] -0.4602838 -1.9242522 -0.8956891  2.1221336  0.8166920
> > .Random.seed <- c(200,979,1479,1542)
> > rnorm(5)
> [1] -1.9242522 -0.8956891  2.1221336  0.8166920 -0.1356919
> > .Random.seed <- c(200,979,1479,1542)
> > rnorm(5)
> [1] -0.4602838 -1.9242522 -0.8956891  2.1221336  0.8166920
> 
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 

-- 
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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] reproducing Box-Muller numbers
Prof Brian D Ripley