View source code
Display the source code in std/random.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla 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
local clone.
Alias std.random.MinstdRand0
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.
Example
// seed with a constant
auto rnd0 = MinstdRand0(1);
auto n = rnd0 .front;
// same for each run
writeln(n); // 16807
// Seed with an unpredictable value
rnd0 .seed(unpredictableSeed);
n = rnd0 .front; // different across runs
Authors
Andrei Alexandrescu Masahiro Nakagawa (Xorshift random generator) Joseph Rushton Wakeling (Algorithm D for random sampling) Ilya Yaroshenko (Mersenne Twister implementation, adapted from mir-random)
License
Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.