package bitgenerators

  1. Overview
  2. Docs

Xoshiro256** is a 64-bit PRNG that uses a carefully constructed linear transformation. This produces a fast PRNG with excellent statistical quality. Xoshiro256** has a period of 2^{256} - 1 and supports jumping the sequence in increments of 2^{128} which allows multiple non-overlapping subsequences to be generated.

The Xoshiro256 state consists of a 4-element tuple of 64-bit unsigned integers. Xoshiro256 is seeded using either a vector of 64-bit unsigned integers. The SeedSequence module is used to generate the required 4 values as initial state.

Xoshiro256 can be used in parallel applications by calling the method Xoshiro256.jump function which advances the state 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 jump : t -> t

jump t is equivalent to 2^{128} calls to Xoshiro256.next_uint64; it can be used to generate 2^{128} non-overlapping subsequences for parallel computations.

OCaml

Innovation. Community. Security.