From a2e9b5a19d874c590b1227f6cd725627345e1214 Mon Sep 17 00:00:00 2001
From: Raimo Niskanen
This module provides a pseudo random number generator.
The module contains a number of algorithms.
- The uniform distribution algorithms use the
+ The uniform distribution algorithms are based on the
For some algorithms, jump functions are provided for generating
- non-overlapping sequences for parallel computations.
- The jump functions perform calculations
- equivalent to perform a large number of repeated calls
- for calculating new states.
+ For most algorithms, jump functions are provided for generating
+ non-overlapping sequences for parallel computations.
+ The jump functions perform calculations
+ equivalent to perform a large number of repeated calls
+ for calculating new states.
+ The following algorithms are provided: Xoroshiro116+, 58 bits precision and period of 2^116-1 Xorshift116**, 58 bits precision and period of 2^116-1 Jump function: equivalent to 2^64 calls Xorshift1024*, 64 bits precision and a period of 2^1024-1 Jump function: equivalent to 2^512 calls
+ This is the Xorshift116 generator combined with the StarStar scrambler
+ from the 2018 paper by David Blackman and Sebastiano Vigna:
+
+ The generator does not need 58-bit rotates so it is faster
+ than the Xoroshiro116 generator, and when combined with
+ the StarStar scrambler it does not have any weak low bits
+ like
+ Alas, this combination is about 10% slower than
Xoroshiro116+, 58 bits precision and period of 2^116-1
+Jump function: equivalent to 2^64 calls
+Xorshift1024*, 64 bits precision and a period of 2^1024-1
+Jump function: equivalent to 2^512 calls
+Xorshift116+, 58 bits precision and period of 2^116-1
@@ -103,7 +129,7 @@
- The default algorithm is
Use a specified algorithm:
-_ = rand:seed(exs1024s), +_ = rand:seed(exs928ss), R2 = rand:uniform(),
Use a specified algorithm with a constant seed:
-_ = rand:seed(exs1024s, {123, 123534, 345345}), +_ = rand:seed(exs928ss, {123, 123534, 345345}), R3 = rand:uniform(),
Use the functional API with a non-constant seed:
-S0 = rand:seed_s(exrop), +S0 = rand:seed_s(exsss), {R4, S1} = rand:uniform_s(S0),
Textbook basic form Box-Muller standard normal deviate
@@ -215,8 +241,9 @@ SND0 = math:sqrt(-2 * math:log(R5)) * math:cos(math:pi() * R6)
- For all these generators except
- If this is a problem; to generate a boolean + If this is a problem; to generate a boolean with these algorithms use something like this:
(rand:uniform(16) > 8)@@ -299,19 +326,19 @@ tests. We suggest to use a sign test to extract a random Boolean value.
Algorithm specific internal state
Algorithm specific internal state
Algorithm specific internal state
Algorithm specific internal state