Learn R Programming

rstream (version 1.2.2)

rstream.runif-class: Class "rstream.runif" -- Interface to Rinternal uniform random number generators

Description

This class implements the "rstream" interface for the Rinternal 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 Ris 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.

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

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