uniform

uniform
(
E = double
size_t N
)
(
size_t[N] length...
)

Examples

import mir.ndslice : all;
import std.algorithm : sum;
import mir.random.variable : BernoulliVariable;
auto bs = BernoulliVariable!double(0.25).generate(100).sum;
assert(0 < bs && bs < 50, "maybe fail");

// pre-defined random variables (normal and uniform)
RNG.setSeed(1);
auto r0 = normal(3, 4).slice;
assert(r0.shape == [3, 4]);
RNG.setSeed(0);
auto r1 = normal(3, 4).slice;
assert(r0 != r1);

RNG.setSeed(0);
auto r2 = normal(3, 4).slice;
assert(r1 == r2);

auto u = uniform(3, 4).slice;
assert(u.shape == [3, 4]);
assert(u.all!(a => (0 <= a && a < 1)));

Meta