[Rd] Interface for package supplied random number generator
Prof Brian Ripley
ripley at stats.ox.ac.uk
Fri Sep 1 17:40:19 CEST 2006
This really is not a good time for us (and apparently you've know about
this for a year). Could you come back to it once 2.4.0 is released (due
[We are busy with getting R-devel ready for 2.4.0, and I think that other
mechanisms for this have been mooted, again at a time which was not
On Thu, 31 Aug 2006, Josef Leydold wrote:
> As you probably know, there is a problem with the interface for adding uniform
> random number generators in R (see by article in R News 5/2, November 2005).
> There exists a mechanism called "user-supplied" that allows users of R
> to run their own generator in R. However, there is no such mechanism for
> package writers. Those who want to add their own generators abuse
> RNGkind(kind="user-supplied") for their purpose.
> The problem with this approach is that it relies on the unique existence of the
> function "user_unif_rand". When two packages are loaded that use this interface,
> then at least one package is broken. If the user herself loads a shared library
> that contains such a function, some of the functionalities of all the
> corresponding packages are broken.
> When writing my paper I found the following packages on CRAN that abuse this
> interface (meanwhile there might be more packages):
> what makes the situation even more complicated is the fact that some of these
> packages are loaded automaticall by other packages.
> For example, package 'rlecuyer' is loaded by
> To solve this problem, Stefan Theussl and I have tried to extend the mechanism
> for random number generators in the following way:
> - we have added a new kind of generators: "package-supplied"
> - this generator kind needs functions named 'package_unif_rand', 'package_unif_init',
> 'package_unif_nseed', and 'package_unif_seedloc'
> (analogously to the functions for kind "user-supplied")
> - RNGkind has an additional optional argument:
> RNGkind <- function(kind = NULL, normal.kind = NULL, PACKAGE = "")
> argument 'PACKAGE' is only used for the new generator kind "package-supplied"
> - similarly the function set.seed needs the optinal argument 'PACKAGE'
> Since I need such an extended interface (and I assume that other package
> write do also) I ask whether this extension can be included into R.
> We have implemented a first experimental version of this modified interface.
> A patch against the development snapshot R-devel_2006-08-30.tar.gz is available.
> However, it is a little bit too long (239 lines) to be posted here.
> Of course suggestions for an alternative approach are welcome.
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
More information about the R-devel