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

This module contains algorithms for the Student's t Distribution.
License:
Authors:
John Michael Hall
pure nothrow @nogc @safe T studentsTPDF(T)(const T x, const T nu)
if (isFloatingPoint!T);
Computes the Student's t probability density function (PDF).
Parameters:
T x value to evaluate PDF
T nu degrees of freedom
pure nothrow @nogc @safe T studentsTPDF(T)(const T x, const T nu, const T mean, const T stdDev)
if (isFloatingPoint!T);
Ditto, with location and scale parameters (by standardizing x).
Parameters:
T x value to evaluate PDF
T nu degrees of freedom
T mean location parameter
T stdDev scale parameter
Examples:
import mir.test: shouldApprox;

studentsTPDF(-3.0, 5).shouldApprox == 0.01729258;
studentsTPDF(-2.0, 5).shouldApprox == 0.06509031;
studentsTPDF(-1.0, 5).shouldApprox == 0.2196798;
studentsTPDF(0.0, 5).shouldApprox == 0.3796067;
studentsTPDF(1.0, 5).shouldApprox == 0.2196798;
studentsTPDF(2.0, 5).shouldApprox == 0.06509031;
studentsTPDF(3.0, 5).shouldApprox == 0.01729258;

// Can include location/scale
studentsTPDF(-3.0, 5, 1, 2).shouldApprox == 0.06509031;
studentsTPDF(-2.0, 5, 1, 2).shouldApprox == 0.1245173;
studentsTPDF(-1.0, 5, 1, 2).shouldApprox == 0.2196798;
studentsTPDF(0.0, 5, 1, 2).shouldApprox == 0.3279185;
studentsTPDF(1.0, 5, 1, 2).shouldApprox == 0.3796067;
studentsTPDF(2.0, 5, 1, 2).shouldApprox == 0.3279185;
studentsTPDF(3.0, 5, 1, 2).shouldApprox == 0.2196798;
pure nothrow @nogc @safe T studentsTCDF(T)(const T x, const T nu)
if (isFloatingPoint!T);
Computes the Student's t cumulative distribution function (CDF).
Parameters:
T x value to evaluate CDF
T nu degrees of freedom
pure nothrow @nogc @safe T studentsTCDF(T)(const T x, const T nu, const T mean, const T stdDev)
if (isFloatingPoint!T);
Ditto, with location and scale parameters (by standardizing x).
Parameters:
T x value to evaluate CDF
T nu degrees of freedom
T mean location parameter
T stdDev scale parameter
Examples:
import mir.test: shouldApprox;

studentsTCDF(-3.0, 5).shouldApprox == 0.01504962;
studentsTCDF(-2.0, 5).shouldApprox == 0.05096974;
studentsTCDF(-1.0, 5).shouldApprox == 0.1816087;
studentsTCDF(0.0, 5).shouldApprox == 0.5;
studentsTCDF(1.0, 5).shouldApprox == 0.8183913;
studentsTCDF(2.0, 5).shouldApprox == 0.9490303;
studentsTCDF(3.0, 5).shouldApprox == 0.9849504;

// Can include location/scale
studentsTCDF(-3.0, 5, 1, 2).shouldApprox == 0.05096974;
studentsTCDF(-2.0, 5, 1, 2).shouldApprox == 0.09695184;
studentsTCDF(-1.0, 5, 1, 2).shouldApprox == 0.1816087;
studentsTCDF(0.0, 5, 1, 2).shouldApprox == 0.3191494;
studentsTCDF(1.0, 5, 1, 2).shouldApprox == 0.5;
studentsTCDF(2.0, 5, 1, 2).shouldApprox == 0.6808506;
studentsTCDF(3.0, 5, 1, 2).shouldApprox == 0.8183913;
pure nothrow @nogc @safe T studentsTCCDF(T)(const T x, const T nu)
if (isFloatingPoint!T);
Computes the Student's t complementary cumulative distribution function (CCDF).
Parameters:
T x value to evaluate CCDF
T nu degrees of freedom
pure nothrow @nogc @safe T studentsTCCDF(T)(const T x, const T nu, const T mean, const T stdDev)
if (isFloatingPoint!T);
Ditto, with location and scale parameters (by standardizing x).
Parameters:
T x value to evaluate CCDF
T nu degrees of freedom
T mean location parameter
T stdDev scale parameter
Examples:
import mir.test: shouldApprox;

studentsTCCDF(-3.0, 5).shouldApprox == 0.9849504;
studentsTCCDF(-2.0, 5).shouldApprox == 0.9490303;
studentsTCCDF(-1.0, 5).shouldApprox == 0.8183913;
studentsTCCDF(0.0, 5).shouldApprox == 0.5;
studentsTCCDF(1.0, 5).shouldApprox == 0.1816087;
studentsTCCDF(2.0, 5).shouldApprox == 0.05096974;
studentsTCCDF(3.0, 5).shouldApprox == 0.01504962;

// Can include location/scale
studentsTCCDF(-3.0, 5, 1, 2).shouldApprox == 0.9490303;
studentsTCCDF(-2.0, 5, 1, 2).shouldApprox == 0.9030482;
studentsTCCDF(-1.0, 5, 1, 2).shouldApprox == 0.8183913;
studentsTCCDF(0.0, 5, 1, 2).shouldApprox == 0.6808506;
studentsTCCDF(1.0, 5, 1, 2).shouldApprox == 0.5;
studentsTCCDF(2.0, 5, 1, 2).shouldApprox == 0.3191494;
studentsTCCDF(3.0, 5, 1, 2).shouldApprox == 0.1816087;
pure nothrow @nogc @safe T studentsTInvCDF(T)(const T p, const T nu)
if (isFloatingPoint!T);
Computes the Student's t inverse cumulative distribution function (InvCDF).
Parameters:
T p value to evaluate InvCDF
T nu degrees of freedom
pure nothrow @nogc @safe T studentsTInvCDF(T)(const T p, const T nu, const T mean, const T stdDev)
if (isFloatingPoint!T);
Ditto, with location and scale parameters (by standardizing x).
Parameters:
T p value to evaluate InvCDF
T nu degrees of freedom
T mean location parameter
T stdDev scale parameter
Examples:
import mir.test: shouldApprox;

studentsTInvCDF(0.0, 5).shouldApprox == -double.infinity;
studentsTInvCDF(0.1, 5).shouldApprox == -1.475884;
studentsTInvCDF(0.2, 5).shouldApprox == -0.9195438;
studentsTInvCDF(0.3, 5).shouldApprox == -0.5594296;
studentsTInvCDF(0.4, 5).shouldApprox == -0.2671809;
studentsTInvCDF(0.5, 5).shouldApprox == 0.0;
studentsTInvCDF(0.6, 5).shouldApprox == 0.2671809;
studentsTInvCDF(0.7, 5).shouldApprox == 0.5594296;
studentsTInvCDF(0.8, 5).shouldApprox == 0.9195438;
studentsTInvCDF(0.9, 5).shouldApprox == 1.475884;
studentsTInvCDF(1.0, 5).shouldApprox == double.infinity;

// Can include location/scale
studentsTInvCDF(0.2, 5, 1, 2).shouldApprox == -0.8390876;
studentsTInvCDF(0.4, 5, 1, 2).shouldApprox == 0.4656382;
studentsTInvCDF(0.6, 5, 1, 2).shouldApprox == 1.534362;
studentsTInvCDF(0.8, 5, 1, 2).shouldApprox == 2.839088;
pure nothrow @nogc @safe T studentsTLPDF(T)(const T x, const T nu)
if (isFloatingPoint!T);
Computes the Student's t log probability density function (LPDF).
Parameters:
T x value to evaluate LPDF
T nu degrees of freedom
pure nothrow @nogc @safe T studentsTLPDF(T)(const T x, const T nu, const T mean, const T stdDev)
if (isFloatingPoint!T);
Ditto, with location and scale parameters (by standardizing x).
Parameters:
T x value to evaluate LPDF
T nu degrees of freedom
T mean location parameter
T stdDev scale parameter
Examples:
import mir.test: shouldApprox;
import mir.math.common: log;

studentsTLPDF(-3.0, 5).shouldApprox == log(0.01729258);
studentsTLPDF(-2.0, 5).shouldApprox == log(0.06509031);
studentsTLPDF(-1.0, 5).shouldApprox == log(0.2196798);
studentsTLPDF(0.0, 5).shouldApprox == log(0.3796067);
studentsTLPDF(1.0, 5).shouldApprox == log(0.2196798);
studentsTLPDF(2.0, 5).shouldApprox == log(0.06509031);
studentsTLPDF(3.0, 5).shouldApprox == log(0.01729258);

// Can include location/scale
studentsTLPDF(-3.0, 5, 1, 2).shouldApprox == log(0.06509031);
studentsTLPDF(-2.0, 5, 1, 2).shouldApprox == log(0.1245173);
studentsTLPDF(-1.0, 5, 1, 2).shouldApprox == log(0.2196798);
studentsTLPDF(0.0, 5, 1, 2).shouldApprox == log(0.3279185);
studentsTLPDF(1.0, 5, 1, 2).shouldApprox == log(0.3796067);
studentsTLPDF(2.0, 5, 1, 2).shouldApprox == log(0.3279185);
studentsTLPDF(3.0, 5, 1, 2).shouldApprox == log(0.2196798);