The OpenD Programming Language

uniformVariable

$(WIKI_D Discrete_uniform).

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

Return Value

Type: UniformVariable!T

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