[R] random number generator?
pgilbert at bank-banque-canada.ca
Wed Jan 29 22:14:02 CET 2003
ripley at stats.ox.ac.uk wrote:
> On Wed, 29 Jan 2003, Paul Gilbert wrote:
> > If reworking the RNG mechanism is considered seriously (and I am not advocating
> > that), I suggest:
> > 1/ There should be a simple mechanism for keeping track of and resetting all the
> > information to generate random numbers, that is, seed, uniform generator, and
> > transformations. (I have a package, which I intend to distribute shortly, that
> > does this for normal distributions and might form a basis for this mechanism. It
> > was previously part of my syskern package in dse, and so the mechanism has been
> > fairly well tested over several years.)
> That's what RNGkind and set.seed do, and have done for a long time.
> The information is also stored in .Random.seed, but few users would record
> that (and it does not exist until the first RNG is used).
Yes, basically I use those and put the information together into an object. The
only other thing I record is version, but have never needed to use that yet. I'm
not suggesting this is especially fancy or complicated, just a lot easier to do
when you use it all the time. It also gives a single object that you can pass to
simulation methods when you want to reproduce something; and pass back from
simulations in the object they generate, so that you don't have to remember to
do anything special and will still be able to reproduce results. Probably the
biggest complication is handling the fact that the seed is not initialized until
the RNG is first called, and this too is relatively trivial to handle.
More information about the R-help