[R] random number generator?

Paul Gilbert pgilbert at bank-banque-canada.ca
Wed Jan 29 20:37:06 CET 2003


Peter Dalgaard BSA wrote:

> As long as the old behaviour can be reinstated, I see very few
> applications that could get in serious trouble. Those who have sample
> output in their books will have greater interest in keeping the
> printed output in sync with their script output than in having perfect
> distributions, but RNGkind() and set.seed() should take care of that

Reproducibility is an issue for me, but having been bitten a long time ago with
S, I think I am now keeping track of all the appropriate information. Even with
the current system, there is not reproducibility unless users have kept track of
the seed. They can probably determine the RNGkind even if they have not recorded
it (if necessary by loading an old version of R from the archives). So, as long
as the old generators and transformations are available, then users should be
able to reproduce results if they ever took the current precautions necessary to
be able to do that. It is possible that there should be a mechanism for
indicating that a set of old defaults should be used.

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

2/ Perhaps there should not be a default behavior, so that users actually have
to initialize something, and get an indication of information they should record
if they want to reproduce the results. That would make it easier to introduce
new RNGs as they are developed.

> -- at least until they have to switch compiler or CPU 

I've actually had pretty good luck with this, even between Splus and R on
different systems. The biggest differences are not the ones you might expect.

Paul Gilbert




More information about the R-help mailing list