Class "rstream.runif" – Interface to R internal uniform random number generators
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 can be created by calls of the form
new("rstream.runif", name, kind, seed, antithetic)
.
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.
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.
The seed for the generator as used by the
set.seed
call. If omitted a random seed is used.
A boolean. Whether or not antithetic random
numbers should be produced.
Default is FALSE
.
Class "rstream"
, directly.
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:
signature(object = "rstream.runif")
:
Get a random sample from the stream object.
signature(object = "rstream.runif")
:
Same as rstream.sample
.
signature(object = "rstream.runif")
:
Reset stream into initial state.
Antithetic random streams:
signature(object = "rstream.runif")
:
Whether or not the stream object returns antithetic random
numbers.
signature(object = "rstream.runif")
:
Change antithetic flag (TRUE
or FALSE
).
Handling "rstream.runif" objects:
signature(x = "rstream.runif")
:
Print state of the stream object.
signature(object = "rstream.runif")
:
The name of the stream object.
signature(object = "rstream.runif")
:
Change the name of the stream object.
signature(object = "rstream.runif")
:
Make a copy (clone) of stream object.
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.
signature(object = "rstream.runif")
:
Whether or not the stream object is packed.
signature(object = "rstream.runif")
:
Pack or unpack object: set packed to TRUE
or FALSE
.
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.
Josef Leydold josef.leydold@wu.ac.at
## 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
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.