package bitgenerators

  1. Overview
  2. Docs

SFC64 is a 256-bit implementation of Chris Doty-Humphrey's Small Fast Chaotic PRNG. It has a few different cycles that one might be on, depending on the seed; the expected period will be about 2^{255}.

It incorporates a 64-bit counter which means that the absolute minimum cycle length is 2^{64} and that distinct seeds will not run into each other for at least 2^{64} iterations. The SFC64 state vector consists of 4 unsigned 64-bit values. The last is a 64-bit counter that increments by 1 each iteration. The input seed is processed by SeedSequence to generate the first 3 values, then the algorithm is iterated a small number of times to mix.

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.

OCaml

Innovation. Community. Security.