Improper.Rng (improper v0.1.0)

A fully deterministic PRNG with the ability to fork new sub-RNGs in a tree structure.

Forks generate their own stream of randomness, but are seeded from the original stream.

A port of java's SplittableRandom as presented in this paper on page 13

Summary

Types

gamma changes every time we split the generator

the seed is changed every time we generate randomness

t()

Functions

Creates a new Rng from a seed.

Generates a random 64-bit float in the 0-1 range, returning the float and a replacement Rng.

Generates a random 32-bit integer in the full integer range, returning the integer and a replacement Rng.

Generates a random 64-bit integer in the full integer range, returning the integer and a replacement Rng.

Splits one Rng into two.

Types

Link to this opaque

gamma()

(opaque)
@opaque gamma()

gamma changes every time we split the generator

Link to this opaque

seed()

(opaque)
@opaque seed()

the seed is changed every time we generate randomness

@type t() :: %Improper.Rng{gamma: gamma(), seed: seed()}

Functions

@spec new(integer()) :: t()

Creates a new Rng from a seed.

Example:

Improper.Rng.new(ExUnit.configuration()[:seed])
Link to this function

next_f64_nif(_, _)

Link to this function

next_float(self)

@spec next_float(t()) :: {float(), t()}

Generates a random 64-bit float in the 0-1 range, returning the float and a replacement Rng.

@spec next_i32(t()) :: {integer(), t()}

Generates a random 32-bit integer in the full integer range, returning the integer and a replacement Rng.

Link to this function

next_i32_nif(_, _)

@spec next_i64(t()) :: {integer(), t()}

Generates a random 64-bit integer in the full integer range, returning the integer and a replacement Rng.

Link to this function

next_i64_between_nif(_, _, _, _)

Link to this function

next_i64_nif(_, _)

Link to this function

next_i64_under_nif(_, _, _)

@spec split(t()) :: {t(), t()}

Splits one Rng into two.

Link to this function

split_nif(_, _)