Rng class final

xoshiro128** 1.1 (Blackman & Vigna 2018), seeded through SplitMix32.

Mutable: each draw advances the state. Create one per aspect with Rng.stream.

Constructors

Rng.fromState(int a, int b, int c, int d)
Raw state constructor (tests and known-answer vectors). The all-zero state is forbidden and replaced by (1, 0, 0, 0).
Rng.stream(int seed, String tag)
The independent sub-stream named tag of seed (seed taken modulo 2^32).
factory

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
state → (int, int, int, int)
The current 128-bit state as four 32-bit words (tests only).
no setter

Methods

nextChance(int numerator, int denominator) → bool
true with probability numerator / denominator.
nextDouble() → double
Double in [0, 1): nextU32() / 2^32, exact on every backend.
nextHueTenths() → int
A hue as integer tenths of a degree, [0, 3600).
nextInt(int n) → int
Unbiased integer in [0, n) for 1 <= n <= 2^32 (rejection sampling: redraw while the raw value is ≥ 2^32 − (2^32 mod n)).
nextIntIn(int lo, int hi) → int
Integer in [lo, hi] (inclusive), unbiased.
nextJitterTenths(int maxTenths) → int
A symmetric jitter in tenths of a degree, [-maxTenths, +maxTenths].
nextU32() → int
The next uniformly distributed 32-bit unsigned integer.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pick<T>(List<T> items) → T
A uniformly chosen element of the non-empty list items.
pickWeighted(List<int> weights) → int
Index into weights (small non-negative integers, sum > 0), chosen with probability proportional to its weight. Integer weights only, so no floating-point cumulative sums can round differently.
range(double lo, double hi) → double
Double in [lo, hi): lo + (hi − lo)·u, deterministic.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited