Report a bug
If you spot a problem with this page, click here to create a Github issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

mir.random.engine

Uniform random engines.
Authors:
Ilya Yaroshenko
template isRandomEngine(T)
Test if T is a random engine. A type should define enum isRandomEngine = true; to be a random engine.
template isSaturatedRandomEngine(T)
Test if T is a saturated random-bit generator. A random number generator is saturated if T.max == ReturnType!T.max. A type should define enum isRandomEngine = true; to be a random engine.
nothrow @nogc @property @trusted size_t unpredictableSeed();
A "good" seed for initializing random number engines. Initializing with unpredictableSeed makes engines generate different random number sequences every run.
Returns:
A single unsigned integer seed value, different on each successive call
Examples:
auto rnd = Random(unpredictableSeed);
auto n = rnd();
static assert(is(typeof(n) == size_t));
alias Random = mir.random.engine.mersenne_twister.MersenneTwisterEngine!(ulong, 64LU, 312LU, 156LU, 31LU, 13043109905998158313LU, 29LU, 6148914691236517205LU, 17LU, 8202884508482404352LU, 37LU, 18444473444759240704LU, 43LU, 6364136223846793005LU).MersenneTwisterEngine;
The "default", "favorite", "suggested" random number generator type on the current platform. It is an alias for one of the generators. You may want to use it if (1) you need to generate some nice random numbers, and (2) you don't care for the minutiae of the method being used.
Examples:
import std.traits;
static assert(isSaturatedRandomEngine!Random);
static assert(is(ReturnType!Random == size_t));