The OpenD Programming Language

MinstdRand

Define LinearCongruentialEngine generators with well-chosen parameters. MinstdRand0 implements Park and Miller's "minimal standard" generator that uses 16807 for the multiplier. MinstdRand implements a variant that has slightly better spectral behavior by using the multiplier 48271. Both generators are rather simplistic.

import mir.random.engine.linear_congruential;
alias MinstdRand = LinearCongruentialEngine!(uint, 48271, 0, 2147483647)

Examples

import mir.random.engine;
// seed with a constant
auto rnd0 = MinstdRand0(1);
auto n = rnd0(); // same for each run
// Seed with an unpredictable value
rnd0 = MinstdRand0(cast(uint)unpredictableSeed);
n = rnd0(); // different across runs

import std.traits;
static assert(is(ReturnType!rnd0 == uint));

Meta