Skip to Content
i documentation
Standard library referenceModules

i/random

Pure, immutable SplitMix generators (§9.10). Pass the returned generator to the next draw. This is not a cryptographic generator. Split and path streams can have equal outputs or states.

Generator

Generator = (Int, State, List(Step), Int)

RandomError

RandomError = InvalidBound | InvalidPath

from_seed

Normalizes any seed modulo 2^64; seeds differing by 2^64 are equal.

from_seed = (seed : Int) -> Generator {

word

One unsigned 64-bit word and the next generator.

word = (g : Generator) -> (Int, Generator) {

int

A value in [0, below), with rejection to avoid modulo bias. InvalidBound carries a nonpositive bound, without drawing a word.

int = (g : Generator, below : Int) -> (Int, Generator) {

float

A Float in [0, 1), using the high 53 bits of one word.

float = (g : Generator) -> (Float, Generator) {

split

Two tagged streams, at split-tree codes 00 and 01.

split = (g : Generator) -> (Generator, Generator) {

at_path

Derives positive path indices. Empty paths preserve the complete generator. InvalidPath carries the whole supplied path, without deriving or drawing.

at_path = (g : Generator, path : List(Int)) -> Generator {