The OpenD Programming Language

bernoulliPMF

Computes the bernoulli probability mass function (PMF).

@safe pure nothrow @nogc
T
bernoulliPMF
(
T
)
(
const bool x
,
const T p
)
if (
isFloatingPoint!T
)

Parameters

x bool

value to evaluate PMF

p T

true probability

Examples

import mir.math.common: approxEqual;

assert(true.bernoulliPMF(0.5) == 0.5);
assert(false.bernoulliPMF(0.5) == 0.5);

assert(true.bernoulliPMF(0.7).approxEqual(0.7));
assert(false.bernoulliPMF(0.7).approxEqual(0.3));

See Also

Meta