package bitgenerators

  1. Overview
  2. Docs

PCG-64 is a 128-bit implementation of O'Neill's permutation congruential generator. PCG-64 has a period of 2^{128} and supports advancing an arbitrary number of steps as well as 2^{127} streams.

The specific member of the PCG family that we use is PCG XSL RR 128/64. The PCG64 state vector consists of 2 unsigned 128-bit values. One is the state of the PRNG, which is advanced by a linear congruential generator (LCG). The second is a fixed odd increment used in the LCG.

The input seed is processed by SeedSequence to generate both values.

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_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 advance : Stdint.int128 -> t -> t

advance delta Advances the underlying RNG as if delta draws have been made. The returned state is that of the generator delta steps forward.

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

next_bounded_uint64 bound t returns an unsigned 64bit integers in the range (0, bound) as well as the state of the generator advanced one step forward.

OCaml

Innovation. Community. Security.