rstream.runif-class: Class "rstream.runif" - Interface to R internal uniform...

Description Objects from the Class Extends Methods Note Author(s) See Also Examples

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).

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.

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 [email protected]

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
## 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

rstream documentation built on June 21, 2017, 5:02 p.m.