tandem rng tandem-ml GitHub

API

Use

let g = Tandem.seed 42
let x, g = Tandem.float g
let n, g = Tandem.below g 1000
let z, g = Tandem.normal g
let a = Bigarray.(Array1.create float64 c_layout 1_000_000)
let g = Tandem.fill_normal g a
let worker = Tandem.split g 7
let g, kids = Tandem.fork g 4

Reference

Single precision

OCaml has no single precision float type. The library has no Float32 draws, fills or normals. Every float is a double from a 64-bit draw.

Parallel use

A fill at an offset reproduces part of a larger fill, so ranks and domains need no coordination:

let part key ~first a =
  Tandem.fill_float (Tandem.seek (Tandem.of_key key) (Int64.of_int (64 * first))) a

A generator and its copies share a cache of the current row. The cache changes no value, but do not use copies of one generator from two domains at once. Give each domain its own generator through split, fork or purpose.