The OpenD Programming Language

UniformVariable

  1. struct UniformVariable(T)
  2. struct UniformVariable(T)

Constructors

this
this(T a, T b)

Constraints: a < b, a and b are finite numbers.

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$(RPAREN)

Examples

import mir.random.engine;
import mir.math : nextDown;
auto gen = Random(unpredictableSeed);
auto rv = uniformVar(-8.0, 10); // [-8, 10)
static assert(isRandomVariable!(typeof(rv)));
auto x = rv(gen); // random variable
assert(rv.min == -8.0);
assert(rv.max == 10.0.nextDown);
import mir.random.engine;
import mir.math : nextDown;
auto gen = Random(unpredictableSeed);
auto rv = UniformVariable!double(-8, 10); // [-8, 10)
foreach(_; 0..1000)
{
    auto x = rv(gen);
    assert(rv.min <= x && x <= rv.max);
}
import mir.random.engine;
import mir.math : nextDown;
Random* gen = threadLocalPtr!Random;
auto rv = UniformVariable!double(-8, 10); // [-8, 10)
auto x = rv(gen); // random variable
assert(rv.min == -8.0);
assert(rv.max == 10.0.nextDown);

Meta