RNGseq: Generate Sequence of Random Streams

Description Usage Arguments Value Functions See Also Examples

View source: R/RNGseq.R

Description

These functions are used to generate independent streams of random numbers.

Usage

1
2
3
4
RNGseq(n, seed = NULL, ..., simplify = TRUE, version = 2)

RNGseq_seed(seed = NULL, normal.kind = NULL, sample.kind = NULL,
  verbose = FALSE, version = 2)

Arguments

n

Number of streams to be created

seed

seed specification used to initialise the set of streams using RNGseq_seed.

...

extra arguments passed to RNGseq_seed.

simplify

a logical that specifies if sequences of length 1 should be unlisted and returned as a single vector.

version

version of the function to use, to reproduce old behaviours. Version 1 had a bug which made the generated stream sequences share most of their seeds (!), as well as being not equivalent to calling set.seed(seed); RNGseq_seed(NULL). Version 2 fixes this bug.

normal.kind

Type of Normal random generator passed to base::RNGkind. See RNG.

sample.kind

Type of Discrete Uniform random generator passed to base::RNGkind. See RNG. Note that this argument is valid for R >= 3.6.0, and an error will be thrown if one tries to use it in previous versions of R.

verbose

logical to toggle verbose messages

Value

a list of integer vectors (or a single integer vector if n=1 and unlist=TRUE).

a 7-length numeric vector.

Functions

See Also

RNGseq

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
RNGseq(3)
RNGseq(3)
RNGseq(3, seed=123)
# or identically
set.seed(123)
identical(RNGseq(3), RNGseq(3, seed=123))


RNGseq(3, seed=1:6, verbose=TRUE)
# select Normal kind
RNGseq(3, seed=123, normal.kind="Ahrens")


## generate a seed for RNGseq
# random  
RNGseq_seed() 
RNGseq_seed()
RNGseq_seed(NULL)
# fixed
RNGseq_seed(1)
RNGseq_seed(1:6)

# `RNGseq_seed(1)` is identical to 
set.seed(1)
s <- RNGseq_seed()
identical(s, RNGseq_seed(1))

 

rngtools documentation built on Sept. 20, 2021, 5:08 p.m.