rstream.lecuyer-class: Class "rstream.lecuyer" - Multiple streams with MRG32k3a...

rstream.lecuyer-classR Documentation

Class "rstream.lecuyer" – Multiple streams with MRG32k3a backbone generator from Pierre L'Ecuyers RngStreams package

Description

This class is obsolete and should be replaced by class "rstream.mrg32k3a"!

This is the old class that implements the "rstream" interface for Pierre L'Ecuyer's RngStreams package with the MRG32K3a multiple recursive generator as its backbone generator. This package is well suited for multiple independent streams of uniform random numbers. In particular it provides antithetic variates and substreams. A very important feature is that different streams are stochastically independent (in opposition to many other random number generators where the uses has to choose seeds carefully). For that reason there only exists a package seed for all streams and indiviual seeds should be avoided (and requires expertise).

Objects from the Class

Objects can be created by calls of the form new("rstream.lecuyer", name, seed, force.seed, antithetic, incprecision).

name:

An arbitrary string to name the stream object. If omitted a string that consists of lecuyer and some number (which is increased every time when a new rstream object is created.

seed:

An array of six numbers. The seed for the RngStreams package. If omitted a random seed is used. It should only be set at the first creation of an instance of an rstream.lecuyer object.

force.see:

A boolean. If the RngStreams package should be reseeded (which is not recommended) it must be TRUE. Default is FALSE.

antithetic:

A boolean. Whether or not antithetic random numbers should be produced. Default is FALSE.

incprecision:

A boolean. Whether or not random numbers with increased precision should be produced. Default is FALSE.

Extends

Class "rstream", directly.

Methods

The class "rstream.lecuyer" provides the following methods for handling "rstream.lecuyer" objects. Some methods that return parameters of the stream object have a variant that uses <- to change the respective parameters. See the man pages for the respective methods for details.

Methods to use the stream:

rstream.sample

signature(object = "rstream.lecuyer"): Get a random sample from the stream object.

r

signature(object = "rstream.lecuyer"): Same as rstream.sample.

rstream.reset

signature(object = "rstream.lecuyer"): Reset stream into initial state.

rstream.nextsubstream

signature(object = "rstream.lecuyer"): Set state of stream to next substream.

rstream.resetsubstream

signature(object = "rstream.lecuyer"): Reset current substream into starting state.

Antithetic random streams and increased precision:

rstream.antithetic

signature(object = "rstream.lecuyer"): Whether or not the stream object returns antithetic random numbers.

rstream.antithetic<-

signature(object = "rstream.lecuyer"): Change antithetic flag (TRUE or FALSE).

rstream.incprecision

signature(object = "rstream.lecuyer"): Whether or not the stream object returns random numbers with increased precision.

rstream.incprecision<-

signature(object = "rstream.lecuyer"): Change flag for increased precision (TRUE or FALSE).

Handling "rstream.lecuyer" objects:

print

signature(x = "rstream.lecuyer"): Print state of the stream object.

rstream.name

signature(object = "rstream.lecuyer"): The name of the stream object.

rstream.name<-

signature(object = "rstream.lecuyer"): Change the name of the stream object.

rstream.clone

signature(object = "rstream.lecuyer"): Make a copy (clone) of stream object.

initialize

signature(.Object = "rstream.lecuyer"): Initialize rstream object. (For Internal usage only).

When a "rstream.lecuyer" object should be used in another R session or saved for some kind of later reuse all information about the object must be packed. Notice no method other than unpacking can be applied to a packed object. It must be unpacked before.

rstream.packed

signature(object = "rstream.lecuyer"): Whether or not the stream object is packed.

rstream.packed<-

signature(object = "rstream.lecuyer"): Pack or unpack object: set packed to TRUE or FALSE.

Warning

The underlying RngStreams library uses a global variable to store the package seed. This variable is also stored inside R. Whenever a new instance of a "rstream.lecuyer" object is created the value of global variable is set to the value of the R object. Thus there is no problem when such "rstream.lecuyer" objects are packed for using in later R sessions. However, if such packed objects are not stored in the workspace image, then the R variable gets lost and there is a (extremely small) chance that newly created objects are not stochastically independent from restored objects.

Note

The slots of this class must not be accessed directly. Use the above methods instead.

"rstream" objects cannot simply be copied by <-. The new variable does not hold a copy of an "rstream" object but just points to the old object which might not be the wanted result (similar to R environments). Use rstream.clone instead.

One may miss a method for reseeding a random stream. However, there is no need for such a method as there is a method for resetting the stream to its initial state. I one needs a stream with a different stream, then a new rstream object should be created at all.

Packed objects must be unpacked before any other method can be applied.

Author(s)

Josef Leydold josef.leydold@wu.ac.at

underlying generator: Pierre L'Ecyuer and Richard Simard

References

L'Ecuyer, P., Simard, R., Chen, E. J., and Kelton, W. D. (2002) An object-oriented random-number package with many long streams and substreams. Operations Research 50(6), 1073-1075.

See Also

rstream, rstream.mrg32k3a, rstream.antithetic-methods, rstream.clone-methods, rstream.incprecision-methods, rstream.name-methods, rstream.packed-methods, rstream.reset-methods, rstream.sample-methods, rstream.nextsubstream-methods, rstream.RNG.

Examples

## create a new rstream.lecuyer object
s <- new("rstream.lecuyer")

## show state of this object
print(s)

## show and change name of stream object
rstream.name(s)
rstream.name(s) <- "mystream"

## get a random number
x <- rstream.sample(s)

## get a random sample of size 100
x <- rstream.sample(s,100)

## reset random stream
rstream.reset(s)

## show and set antithetic flag
rstream.antithetic(s)
rstream.antithetic(s) <- TRUE

## jump to next substream
rstream.nextsubstream(s)

## make a clone of the rstream object
sc <- rstream.clone(s)

## pack and unpack the rstream object
rstream.packed(s) <- TRUE
rstream.packed(s) <- FALSE


rstream documentation built on Oct. 19, 2022, 5:30 p.m.