.rng is a list containing the state of the uniform pseudorandom number generator (with components seed, method and parameters). It is advisable to use set.rng() to set it.

rng() returns a sequence of uniform pseudorandom numbers (using the generator selected with set.rng()).

rlcg() returns a sequence of uniform pseudorandom numbers using the linear congruential generator (LCG).

rvng() returns a sequence of uniform pseudorandom numbers using the Von Neumann middle-square method.

set.rng(seed = as.numeric(Sys.time()), type = c("lcg", "vng"), ...)

rng(n)

rlcg(n, seed = as.numeric(Sys.time()), a = 7^5, c = 0, m = 2^31 - 1)

rvng(n, seed = as.numeric(Sys.time()), k = 4)

Arguments

seed

initial seed.

type

string specifying the generator.

...

generator parameters.

n

number of generations.

a

multiplier.

c

increment.

m

modulus.

k

number of digits.

Value

set.rng() stores the state of the generator in .rng in the global environment.

rng(), rlcg() and rvmg() return a numeric vector.

Examples

print(set.rng())
#> $seed
#> [1] 1698920300
#> 
#> $type
#> [1] "lcg"
#> 
#> $parameters
#> $parameters$a
#> [1] 16807
#> 
#> $parameters$c
#> [1] 0
#> 
#> $parameters$m
#> [1] 2147483647
#> 
#> 
rng(10)
#>  [1] 0.3776134 0.5486907 0.8447358 0.4742613 0.9093104 0.7800892 0.9595596
#>  [8] 0.3175281 0.6951973 0.1803428
.rng
#> $seed
#> [1] 387283206
#> 
#> $type
#> [1] "lcg"
#> 
#> $parameters
#> $parameters$a
#> [1] 16807
#> 
#> $parameters$c
#> [1] 0
#> 
#> $parameters$m
#> [1] 2147483647
#> 
#>