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.uniform

This module contains algorithms for the continuous Uniform Distribution.
License:
Authors:
John Michael Hall
pure nothrow @nogc @safe T uniformPDF(T)(const T x, const T lower = 0, const T upper = 1)
if (isFloatingPoint!T);
Computes the uniform probability density function (PDF).
Parameters:
T x value to evaluate PDF
T lower lower bound
T upper upper bound
Examples:
import mir.math.common: approxEqual;
assert(0.5.uniformPDF == 1);
assert(0.5.uniformPDF(0.0, 1.5).approxEqual(2.0 / 3));
assert(2.5.uniformPDF(1.0, 3.0).approxEqual(0.5));
pure nothrow @nogc @safe T uniformCDF(T)(const T x, const T lower = 0, const T upper = 1)
if (isFloatingPoint!T);
Computes the uniform cumulative distribution function (CDF).
Parameters:
T x value to evaluate CDF
T lower lower bound
T upper upper bound
Examples:
import mir.math.common: approxEqual;
assert(0.5.uniformCDF == 0.5);
assert(0.5.uniformCDF(0.0, 1.5).approxEqual(1.0 / 3));
assert(2.5.uniformCDF(1.0, 3.0).approxEqual(3.0 / 4));
pure nothrow @nogc @safe T uniformCCDF(T)(const T x, const T lower = 0, const T upper = 1)
if (isFloatingPoint!T);
Computes the uniform complementary cumulative distribution function (CCDF).
Parameters:
T x value to evaluate CCDF
T lower lower bound
T upper upper bound
Examples:
import mir.math.common: approxEqual;
assert(0.5.uniformCCDF == 0.5);
assert(0.5.uniformCCDF(0.0, 1.5).approxEqual(2.0 / 3));
assert(2.5.uniformCCDF(1.0, 3.0).approxEqual(1.0 / 4));
pure nothrow @nogc @safe T uniformInvCDF(T)(const T p, const T lower = 0, const T upper = 1)
if (isFloatingPoint!T);
Computes the uniform inverse cumulative distribution function (InvCDF)
Parameters:
T p value to evaluate InvCDF
T lower lower bound
T upper upper bound
Examples:
import mir.math.common: approxEqual;
assert(0.5.uniformInvCDF == 0.5);
assert((1.0 / 3).uniformInvCDF(0.0, 1.5).approxEqual(0.5));
assert((3.0 / 4).uniformInvCDF(1.0, 3.0).approxEqual(2.5));
pure nothrow @nogc @safe T uniformLPDF(T)(const T x, const T lower = 0, const T upper = 1)
if (isFloatingPoint!T);
Computes the uniform log probability density function (LPDF)
Parameters:
T x value to evaluate LPDF
T lower lower bound
T upper upper bound
Examples:
import mir.math.common: approxEqual, log;
assert(0.5.uniformLPDF == 0);
assert(0.5.uniformLPDF(0.0, 1.5).approxEqual(-log(1.5)));
assert(1.5.uniformLPDF(1.0, 3.0).approxEqual(-log(2.0)));