Module Bitgen.LXM

The LXM generator combines two simple generators with an optional additional hashing of the output. The first generator is a LCG of with and update s = a s + b \mod 2^{64} where a is 2862933555777941757 and b is settable. The default value of b is 3037000493. The second is the standard 64-bit xorshift generator.

The output of these two is combined using addition. This sum is hashed using the Murmur3 hash function using the parameters suggested by David Stafford. Is pseudo-code, each value is computed as Mix(LCG + Xorshift).

The LXM state vector consists of a 4-element array of 64-bit unsigned integers that constraint the state of the Xorshift generator and an addition 64-bit unsigned integer that holds the state of the LCG. These initial states are set using SeedSequence

LXM can be used in parallel applications by calling LXM.jump which provides a new instance with a state that has been updated as-if 2^{128} random numbers have been generated. This allows the original sequence to be split so that distinct segments can be used in each worker process.

type t

t is the state of the bitgenerator.

val next_uint64 : t -> Stdint.uint64 * t

next_uint64 t Generates a random unsigned 64-bit integer and a state of the generator advanced forward by one step.

val next_uint32 : t -> Stdint.uint32 * t

next_uint32 t Generates a random unsigned 32-bit integer and a state of the generator advanced forward by one step.

val next_bounded_uint64 : Stdint.uint64 -> t -> Stdint.uint64 * t

next_bounded_uint64 b t Generates a random unsigned 64-bit integer in the interval [0, b). It returns the integer as well as the state of the generator advanced forward. To generate an integer in the range [a, b), one should generate an integer in [0, b - a) using next_bounded_uint64 (b - a) t and then add a to the resulting integer to get the output in the desired range.

val next_double : t -> float * t

next_double t Generates a random 64 bit float and a state of the generator advanced forward by one step.

val initialize : Bitgen__.Seed.SeedSequence.t -> t

initialize s Returns the initial state of the generator. The random stream is determined by the initialization of the seed sequence s of SeedSequence.t type.

val initialize_full : Stdint.uint64 -> Bitgen__.Seed.SeedSequence.t -> t

initialize_full b seedseq initialiazes the state of the LXM generator where b is the settable additive constant of the underlying LCG generator.

val jump : t -> t

jump t is equivalent to 2^{128} calls to LXM.next_uint64.