getRNG
returns the Random Number Generator (RNG)
settings used for computing an object, using a suitable
.getRNG
S4 method to extract these settings. For
example, in the case of objects that result from multiple
model fits, it would return the RNG settings used to
compute the best fit.
hasRNG
tells if an object has embedded RNG data.
.getRNG
is an S4 generic that extract RNG settings
from a variety of object types. Its methods define the
workhorse functions that are called by getRNG
.
getRNG1
is defined to provide separate access to
the RNG settings as they were at the very beginning of a
whole computation, which might differ from the RNG
settings returned by getRNG
, that allows to
reproduce the result only.
nextRNG
returns the RNG settings as they would be
after seeding with object
.
setRNG
set the current RNG with a seed, using a
suitable .setRNG
method to set these settings.
.setRNG
is an S4 generic that sets the current RNG
settings, from a variety of specifications. Its methods
define the workhorse functions that are called by
setRNG
.
getRNG(object, ..., num.ok = FALSE, extract = TRUE, recursive = TRUE) hasRNG(object) .getRNG(object, ...) getRNG1(object, ...) nextRNG(object, ..., ndraw = 0L) setRNG(object, ..., verbose = FALSE, check = TRUE) .setRNG(object, ...)
.Random.seed
or embedded RNG data, e.g.,
in S3/S4 slot rng
or rng$noise
..getRNG
or
.setRNG
.TRUE
) or passed to
set.seed
into a proper RNG seed
(FALSE
) (See details and examples).TRUE
) or
if the object itself should be considered as an RNG
specification.TRUE
) or
only once (FASE
).getRNG
, getRNG1
, nextRNG
and
setRNG
usually return an integer vector of length
> 2L, like .Random.seed
.
getRNG
and getRNG1
return NULL
if no
RNG data was found.
setRNG
invisibly returns the old RNG settings as
they were before changing them.
This function handles single number RNG specifications in the following way:
RNG
). No validity check
is performed. num.ok=TRUE
return them unchanged. Otherwise, consider them as
(pre-)seeds and pass them to set.seed
to
get a proper RNG seed. Hence calling getRNG(1234)
is equivalent to set.seed(1234); getRNG()
(See
examples). Think of a sequence of separate computations, from which
only one result is used for the result (e.g. the one that
maximises a likelihood): getRNG1
would return the
RNG settings to reproduce the complete sequence of
computations, while getRNG
would return the RNG
settings necessary to reproduce only the computation
whose result has maximum likelihood.
signature(object = "ANY")
: Default
method that tries to extract RNG information from
object
, by looking sequentially to a slot named
'rng'
, a slot named 'rng.seed'
or an
attribute names 'rng'
.
It returns NULL
if no RNG data was found.
signature(object = "missing")
:
Returns the current RNG settings.
signature(object = "list")
: Method
for S3 objects, that aims at reproducing the behaviour of
the function getRNG
of the package getRNG
.
It sequentially looks for RNG data in elements
'rng'
, noise$rng
if element 'noise'
exists and is a list
, or in attribute
'rng'
.
signature(object = "numeric")
:
Method for numeric vectors, which returns the object
itself, coerced into an integer vector if necessary, as
it is assumed to already represent a value for
.Random.seed
.
signature(object = "ANY")
: Default
method that is identical to getRNG(object, ...)
.
signature(object = "character")
:
Sets the RNG to kind object
, assuming is a valid
RNG kind: it is equivalent to RNGkind(object, ...
.
All arguments in ...
are passed to
RNGkind
.
signature(object = "numeric")
: Sets
the RNG settings using object
directly the new
value for .Random.seed
or to initialise it with
set.seed
.