Report a bug
If you spot a problem with this page, click here to create a GitHub issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

mir.stat.distribution.beta

This module contains algorithms for the Beta Distribution.
An alternate parameterization of this distribution is provided in mir.stat.distribution.beta_proportion.
License:
Authors:
John Michael Hall
pure nothrow @nogc @safe T betaPDF(T)(const T x, const T alpha, const T beta)
if (isFloatingPoint!T);
Computes the beta probability density function (PDF).
Parameters:
T x value to evaluate PDF
T alpha shape parameter #1
T beta shape parameter #2
Examples:
import mir.math.common: approxEqual;

assert(0.5.betaPDF(1, 1) == 1);
assert(0.75.betaPDF(1, 2).approxEqual(0.5));
assert(0.25.betaPDF(0.5, 4).approxEqual(0.9228516));
pure nothrow @nogc @safe T betaCDF(T)(const T x, const T alpha, const T beta)
if (isFloatingPoint!T);
Computes the beta cumulatve distribution function (CDF).
Parameters:
T x value to evaluate CDF
T alpha shape parameter #1
T beta shape parameter #2
Examples:
import mir.math.common: approxEqual;

assert(0.5.betaCDF(1, 1).approxEqual(0.5));
assert(0.75.betaCDF(1, 2).approxEqual(0.9375));
assert(0.25.betaCDF(0.5, 4).approxEqual(0.8588867));
pure nothrow @nogc @safe T betaCCDF(T)(const T x, const T alpha, const T beta)
if (isFloatingPoint!T);
Computes the beta complementary cumulative distribution function (CCDF).
Parameters:
T x value to evaluate CCDF
T alpha shape parameter #1
T beta shape parameter #2
Examples:
import mir.math.common: approxEqual;

assert(0.5.betaCCDF(1, 1).approxEqual(0.5));
assert(0.75.betaCCDF(1, 2).approxEqual(0.0625));
assert(0.25.betaCCDF(0.5, 4).approxEqual(0.1411133));
pure nothrow @nogc @safe T betaInvCDF(T)(const T p, const T alpha, const T beta)
if (isFloatingPoint!T);
Computes the beta inverse cumulative distribution function (InvCDF).
Parameters:
T p value to evaluate InvCDF
T alpha shape parameter #1
T beta shape parameter #2
Examples:
import mir.math.common: approxEqual;

assert(0.5.betaInvCDF(1, 1).approxEqual(0.5));
assert(0.9375.betaInvCDF(1, 2).approxEqual(0.75));
assert(0.8588867.betaInvCDF(0.5, 4).approxEqual(0.25));
pure nothrow @nogc @safe T betaLPDF(T)(const T x, const T alpha, const T beta)
if (isFloatingPoint!T);
Computes the beta log probability density function (LPDF).
Parameters:
T x value to evaluate LPDF
T alpha shape parameter #1
T beta shape parameter #2
Examples:
import mir.math.common: approxEqual, log;

assert(0.5.betaLPDF(1, 1).approxEqual(log(betaPDF(0.5, 1, 1))));
assert(0.75.betaLPDF(1, 2).approxEqual(log(betaPDF(0.75, 1, 2))));
assert(0.25.betaLPDF(0.5, 4).approxEqual(log(betaPDF(0.25, 0.5, 4))));