[Rd] Interface for package supplied random number generator

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Sep 1 17:46:36 CEST 2006


On Fri, 1 Sep 2006, Prof Brian Ripley wrote:

> 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 
> Oct 23)?

Oops, a backspace failed:  Oct 3.

> 
> [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 
> opportune.]
> 
> On Thu, 31 Aug 2006, Josef Leydold wrote:
> 
> > Hi,
> > 
> > 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):
> > 
> > randaes_0.1.tar.gz
> > rlecuyer_0.1.tar.gz
> > rsprng_0.3-1.tar.gz
> > rstream_1.1.tar.gz
> > SuppDists_1.0-13.tar.gz
> > 
> > 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
> > 
> > snow_0.2-1.tar.gz
> > snowFT_0.0-1.tar.gz
> > varSelRF_0.6-2.tar.gz
> > 
> > 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.
> > 
> > Josef
> > 
> > 
> > 
> 
> 

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