Learn R Programming

rstream (version 1.3.7)

rstream.runif-class: 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.

Arguments

Objects from the Class

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

name:

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

kind:

A character string. The new "rstream" object uses the RNG of type kind. The same strings as for RNGkind can be used. Additionally the string "current" is available to use the type of generator to which R is currently set (this is the default if no kind is given). User-supplied generators cannot be used.

seed:

The seed for the generator as used by the set.seed call. If omitted a random seed is used.

antithetic:

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

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.

Author

Josef Leydold josef.leydold@wu.ac.at

See Also

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

Examples

Run this code
## 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

Run the code above in your browser using DataLab