The OpenD Programming Language

uniformVariable

  1. UniformVariable!T uniformVariable(T a, T b)
  2. UniformVariable!T uniformVariable(T a, T b)
    version(D_Ddoc)
    uniformVariable
    (
    T = double
    )
    (
    in T a
    ,
    in T b
    )

Return Value

Type: UniformVariable!T

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