Formatting RNG Information

Usage

RNGstr(object, n = 7L, ...)

RNGtype(object, ..., provider = FALSE)

showRNG(object = getRNG(), indent = "#", ...)

RNGinfo(object = getRNG(), ...)

RNGdigest(object = getRNG())

Arguments

object
RNG seed (i.e. an integer vector), or an object that contains embedded RNG data. For RNGtype this must be either a valid RNG seed or a single integer that must be a valid encoded RNG kind (see RNGkind).
n
maximum length for a seed to be showed in full. If the seed has length greater than n, then only the first three elements are shown and a digest hash of the complete seed is appended to the string.
provider
logical that indicates if the library that provides the RNG should also be returned as a third element.
indent
character string to use as indentation prefix in the output from showRNG.
...
extra arguments passed to RNGtype.

Value

a single character string

RNGtype returns a 2 or 3-long character vector.

Description

These functions retrieve/prints formated information about RNGs.

RNGtype returns the same type of values as RNGkind() (character strings), except that it can extract the RNG settings from an object. If object is missing it returns the kinds of the current RNG settings, i.e. it is identical to RNGkind().

showRNG displays human readable information about RNG settings. If object is missing it displays information about the current RNG.

RNGinfo is equivalent to RNGtype but returns a named list instead of an unnamed character vector.

RNGdigest computes a hash from the RNG settings associated with an object.

Details

All functions can retrieve can be called with objects that are -- valid -- RNG seeds or contain embedded RNG data, but none of them change the current RNG setting. To effectively change the current settings on should use setRNG.

RNGstr returns a description of an RNG seed as a single character string.

RNGstr formats seeds by collapsing them in a comma separated string. By default, seeds that contain more than 7L integers, have their 3 first values collapsed plus a digest hash of the complete seed.

Examples

# default is a 626-long integer
RNGstr()
[1] "403L, 1L, ..., 1450597184L [833acd4e4ba35d1452512fffa0888c3f]"
# what would be the seed after seeding with set.seed(1234)
RNGstr(1234)
[1] "403L, 624L, ..., -1896522223L [eacb7c1288e03421d428feb736099548]"
# another RNG (short seed)
RNGstr(c(401L, 1L, 1L))
[1] "401L, 1L, 1L"
# no validity check is performed
RNGstr(2:3)
[1] "2L, 3L"
# get RNG type
RNGtype()
[1] "Mersenne-Twister" "Inversion"
RNGtype(provider=TRUE)
[1] "Mersenne-Twister" "Inversion" "base"
RNGtype(1:3)
[1] "Marsaglia-Multicarry" "Buggy Kinderman-Ramage"
# type from encoded RNG kind
RNGtype(107L)
[1] "L'Ecuyer-CMRG" "Ahrens-Dieter"
# this is different from the following which treats 107 as a seed for set.seed
RNGtype(107)
[1] "Mersenne-Twister" "Inversion"
showRNG()
# RNG kind: Mersenne-Twister / Inversion # RNG state: 403L, 1L, ..., 1450597184L [833acd4e4ba35d1452512fffa0888c3f]
# as after set.seed(1234)
showRNG(1234)
# RNG kind: Mersenne-Twister / Inversion # RNG state: 403L, 624L, ..., -1896522223L [eacb7c1288e03421d428feb736099548]
showRNG()
# RNG kind: Mersenne-Twister / Inversion # RNG state: 403L, 1L, ..., 1450597184L [833acd4e4ba35d1452512fffa0888c3f]
set.seed(1234)
showRNG()
# RNG kind: Mersenne-Twister / Inversion # RNG state: 403L, 624L, ..., -1896522223L [eacb7c1288e03421d428feb736099548]
# direct seeding
showRNG(1:3)
# RNG kind: Marsaglia-Multicarry / Buggy Kinderman-Ramage # RNG state: 1L, 2L, 3L
# this does not change the current RNG
showRNG()
# RNG kind: Mersenne-Twister / Inversion # RNG state: 403L, 624L, ..., -1896522223L [eacb7c1288e03421d428feb736099548]
showRNG(provider=TRUE)
# RNG kind: Mersenne-Twister / Inversion [base] # RNG state: 403L, 624L, ..., -1896522223L [eacb7c1288e03421d428feb736099548]
# get info as a list
RNGinfo()
$kind [1] "Mersenne-Twister" $normal [1] "Inversion"
RNGinfo(provider=TRUE)
$kind [1] "Mersenne-Twister" $normal [1] "Inversion" $provider [1] "base"
# from encoded RNG kind
RNGinfo(107)
$kind [1] "Mersenne-Twister" $normal [1] "Inversion"
# compute digest hash from RNG settings
RNGdigest()
[1] "eacb7c1288e03421d428feb736099548"
RNGdigest(1234)
[1] "eacb7c1288e03421d428feb736099548"
# no validity check is performed
RNGdigest(2:3)
[1] "9d1bafcc4a1a18040eb8ba710712e25c"