The OpenD Programming Language

UniformVariable

$(WIKI_D Discrete_uniform).

Constructors

this
this(T a, T b)

Constraints: a <= b.

Members

Functions

max
T max()
min
T min()
opCall
T opCall(G gen)
T opCall(G* gen)

Manifest constants

isRandomVariable
enum isRandomVariable;

Return Value

X ~ U[a, b]

Examples

import mir.random.engine;
auto gen = Random(unpredictableSeed);
auto rv = uniformVar(-10, 10); // [-10, 10]
static assert(isRandomVariable!(typeof(rv)));
auto x = rv(gen); // random variable
assert(rv.min == -10);
assert(rv.max == 10);
import mir.random.engine;
Random* gen = threadLocalPtr!Random;
auto rv = UniformVariable!int(-10, 10); // [-10, 10]
auto x = rv(gen); // random variable
assert(rv.min == -10);
assert(rv.max == 10);

Meta