local_lecuyer_cmrg_state() sets the L'Ecuyer-CMRG RNG state to a
.Random.seed-style integer vector (length 7) by assigning to
.Random.seed directly, restoring the previous state when .local_envir
exits. with_lecuyer_cmrg_state() evaluates code with that state in
effect, then restores the previous state. A state is the full internal
RNG state (as returned by parallel::nextRNGStream() or
get_lecuyer_cmrg_stream_state()); contrast with base::set.seed()
which takes a scalar seed (see local_lecuyer_cmrg_seed() /
with_lecuyer_cmrg_seed()).
Usage
local_lecuyer_cmrg_state(state, .local_envir = parent.frame())
with_lecuyer_cmrg_state(state, code)Value
local_lecuyer_cmrg_state() invisibly returns state;
with_lecuyer_cmrg_state() returns the value of code.
Examples
state <- with_lecuyer_cmrg_seed(42, parallel::nextRNGStream(.Random.seed))
local_lecuyer_cmrg_state(state)
runif(3)
#> [1] 0.1738456 0.5547401 0.4833771
with_lecuyer_cmrg_state(state, runif(3))
#> [1] 0.8685000 0.1017511 0.4696414