Pseudorandom Numbers
Using a Linear Congruential Generator
RandomVariates.gen_prn
— Functiongen_prn()
Generate a pseudorandom number.
Notes
Uses a linear congruential generator (LCG) with POSIX parameters:
$X_n = 25214903917 X_{n-1} + 11 \quad mod \quad 2^{48}$
Examples
julia> gen_prn()
156750217634815
julia> gen_prn()
63914890472862
Using a Tausworthe Generator
RandomVariates.tausworthe_rng
— Functiontausworthe_rng(shape::Int=1; r::Int=3, q::Int=128)
Generate a shape
element array of random variables from a standard Uniform(0,1) distribution using a Tausworthe RNG.
Notes
Implementation:
$B_i = B_{i-r} \quad XOR \quad B_{i-q}$
Examples
julia> U = tausworthe_rng(1)
1-element Vector{Float64}:
0.5462285033427179
julia> U = tausworthe_rng((2,2))
2×2 Matrix{Float64}:
0.782613 0.365878
0.176636 0.0413817
References
Shu Tezuka and Pierre L'Ecuyer. 1991. Efficient and portable combined Tausworthe random number generators. ACM Trans. Model. Comput. Simul. 1, 2 (April 1991), 99–112. DOI:https://doi.org/10.1145/116890.116892
Law, A. Simulation modeling and analysis, 5th Ed. McGraw Hill Education, Tuscon, 2013.