The OpenD Programming Language

bernoulliLPMF

Computes the bernoulli log probability mass function (LPMF).

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

Parameters

x bool

value to evaluate LPDF

p T

true probability

Examples

import mir.math.common: approxEqual, log;

assert(true.bernoulliLPMF(0.5).approxEqual(log(bernoulliPMF(true, 0.5))));
assert(false.bernoulliLPMF(0.5).approxEqual(log(bernoulliPMF(false, 0.5))));

assert(true.bernoulliLPMF(0.7).approxEqual(log(bernoulliPMF(true, 0.7))));
assert(false.bernoulliLPMF(0.7).approxEqual(log(bernoulliPMF(false, 0.7))));

See Also

Meta