RNGstr: Formatting RNG Information

Description Usage Arguments Details Value Functions Examples

View source: R/format.R

Description

These functions retrieve/prints formated information about RNGs.

Usage

1
2
3
4
5
6
7
8
9
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.

...

extra arguments passed to RNGtype.

provider

logical that indicates if the library that provides the RNG should also be returned as an extra element.

indent

character string to use as indentation prefix in the output from showRNG.

Details

All functions 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.

Value

a single character string

RNGtype returns a named character vector containing the types of the random number generator, which correspond to the arguments accepted by base::RNGkind. Note that starting with R 3.6, the vector has length 3, while in previous R versions it has length 2 (no sample.kind element).

Functions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# default is a 626-long integer
RNGstr()
# what would be the seed after seeding with set.seed(1234)
RNGstr(1234)
# another RNG (short seed)
RNGstr(c(401L, 1L, 1L))
# no validity check is performed 
RNGstr(2:3)


# get RNG type
RNGtype()
RNGtype(provider=TRUE)
RNGtype(1:3)

# type from encoded RNG kind
RNGtype(107L)
# this is different from the following which treats 107 as a seed for set.seed
RNGtype(107)

showRNG()
# as after set.seed(1234)
showRNG(1234)
showRNG()
set.seed(1234)
showRNG()
# direct seeding
showRNG(1:3)
# this does not change the current RNG
showRNG()
showRNG(provider=TRUE)

# get info as a list
RNGinfo()
RNGinfo(provider=TRUE)
# from encoded RNG kind
RNGinfo(107)

# compute digest hash from RNG settings
RNGdigest()
RNGdigest(1234)
# no validity check is performed
RNGdigest(2:3)

renozao/rngtools documentation built on Sept. 24, 2021, 11:14 p.m.