rcrng-class: rcrng

Description Details Fields Methods Examples

Description

Pseudo-random number generator

Details

This is the main reference class of this package. Use it to create pseudo-random number generators for random variables and vectors. Currently it is assumed that the core algorithm behind any rng object is Pierre L'Ecuyer's MRG32k3a. This assumption may be relaxed in future versions of this package.

Fields

rng.name

character. Name of the pseudo-random number generator object.

n.substreams

numeric. Number of substreams in the object.

anti

logical. Use anthitetical uniform variates (1-x) instead?

inc.prec

logical. Use variates with increased precision (53 bits)?

resettable

logical. Should the RNG be resettable?

cg

matrix. State matrix 1.

bg

matrix. State matrix 2.

ig

numeric. State matrix 3.

algorithm

rcmrg32k3a. Algorithm that advances the state matrix.

Methods

advance.state(ee, cc, i = 1)

Advances the state by 2 ^ ee + cc units

antithetic(value = NULL)

If value = TRUE, the stream will start generating antithetic variates, i.e., 1-U instead of U.

high.precision(value = NULL)

With value = TRUE, each call to the algorithm (direct or indirect) for this stream will return a uniform random number with 53 bits of resolution instead of 32 bits, and will advance the state of the stream by 2 steps instead of 1

initialize(n.substreams = 1, name = NULL, high.precision = FALSE, antithetic = FALSE, resettable = TRUE, ...)

Creates a new random number generator. The actual algorithm may be created (default) or passed by reference.

next.substream(i = 1)

Moves a stream to the beginning of its next substream.

reset()

Reinitializes the streams and substreams to their initial states, i.e., if n = 1 (one stream only), cg and bg are set to ig; if n > 1 (multiple substreams), cg is set to bg.

rint(lb, ub, n = 1)

Returns a pseudo-random number from the discrete uniform distribution over the integers (i, i + 1, ... j). Makes one call to runif.

runif(n = 1, n.ascolumn = TRUE)

Returns n pseudo-random numbers from the (0, 1) uniform distribution. In normal mode, the returned numbers have 32 bits of precision (i.e., they are multiples of 1 / (2 ^ 32 - 208)) and the state is advanced by one step per variate. In Increased Precision mode, returned numbers have 53 bits of precision, and the state is advanced by two steps per variate.

seed(new.seed = NULL)

Provides current seed or sets a new seed, to produce the stream and substreams. Input value = vector with 6 integers.

Examples

1
2
h <- rcrng()
h$runif()

rtlemos/rcrandom documentation built on May 28, 2019, 9:55 a.m.