rstream.runif-class {rstream}R Documentation

Class "rstream.runif" – Interface to R internal uniform random number generators

Description

This class implements the "rstream" interface for the R internal uniform RNGs. This class allows to access and handle these generators in exactly the same way as external generators. In particular, one can create copies of generators. There is no need to deal with RNGkind and set.seed when different RNGs should be used.

Objects from the Class

Objects can be created by calls of the form new("rstream.runif", name, kind, seed, antithetic).

Extends

Class "rstream", directly.

Methods

The class "rstream.runif" provides the following methods for handling "rstream.runif" 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.runif"): Get a random sample from the stream object.
r
signature(object = "rstream.runif"): Same as rstream.sample.
rstream.reset
signature(object = "rstream.runif"): Reset stream into initial state.

Antithetic random streams:

rstream.antithetic
signature(object = "rstream.runif"): Whether or not the stream object returns antithetic random numbers.
rstream.antithetic<-
signature(object = "rstream.runif"): Change antithetic flag (TRUE or FALSE).

Handling "rstream.runif" objects:

print
signature(x = "rstream.runif"): Print state of the stream object.
rstream.name
signature(object = "rstream.runif"): The name of the stream object.
rstream.name<-
signature(object = "rstream.runif"): Change the name of the stream object.
rstream.clone
signature(object = "rstream.runif"): Make a copy (clone) of stream object.
initialize
signature(.Object = "rstream.runif"): Initialize rstream object. (For Internal usage only).

When a "rstream.runif" 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.runif"): Whether or not the stream object is packed.
rstream.packed<-
signature(object = "rstream.runif"): Pack or unpack object: set packed to TRUE or FALSE.

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 (leydold@statistik.wu-wien.ac.at)

See Also

rstream-class, rstream.antithetic-methods, rstream.clone-methods, rstream.name-methods, rstream.packed-methods, rstream.reset-methods, rstream.sample-methods, rstream.RNG.

Examples

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

## 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

## 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


[Package rstream version 1.2.3 Index]