The OpenD Programming Language

DirichletVariable

Dirichlet distribution.

Constructors

this
this(const(T)[] alpha)

Members

Aliases

Element
alias Element = T
opCall
void opCall(G* gen, T[] result)

Functions

opCall
void opCall(G gen, T[] result)

Manifest constants

isNdRandomVariable
enum isNdRandomVariable;

Variables

alpha
const(T)[] alpha;

Examples

import mir.random.engine;
import mir.math.common: fabs;

auto rv = dirichletVar([1.0, 5.7, 0.3]);
double[3] x;
rv(rne, x);
assert(x[0] >= 0 && x[1] >= 0 && x[2] >= 0);
assert(fabs(x[0] + x[1] + x[2] - 1) < 1e-10);
import mir.random.engine;
import mir.math.common: fabs;

Random* gen = threadLocalPtr!Random;
auto rv = DirichletVariable!double([1.0, 5.7, 0.3]);
double[3] x;
rv(gen, x);
assert(x[0] >= 0 && x[1] >= 0 && x[2] >= 0);
assert(fabs(x[0] + x[1] + x[2] - 1) < 1e-10);

Meta