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

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

cauchyPDF(-3.0).shouldApprox == 0.03183099;
cauchyPDF(-2.0).shouldApprox == 0.06366198;
cauchyPDF(-1.0).shouldApprox == 0.1591549;
cauchyPDF(0.0).shouldApprox == 0.3183099;
cauchyPDF(1.0).shouldApprox == 0.1591549;
cauchyPDF(2.0).shouldApprox == 0.06366198;
cauchyPDF(3.0).shouldApprox == 0.03183099;

// Can include location/scale
cauchyPDF(-3.0, 1, 2).shouldApprox == 0.03183099;
cauchyPDF(-2.0, 1, 2).shouldApprox == 0.04897075;
cauchyPDF(-1.0, 1, 2).shouldApprox == 0.07957747;
cauchyPDF(0.0, 1, 2).shouldApprox == 0.127324;
cauchyPDF(1.0, 1, 2).shouldApprox == 0.1591549;
cauchyPDF(2.0, 1, 2).shouldApprox == 0.127324;
cauchyPDF(3.0, 1, 2).shouldApprox == 0.07957747;
pure nothrow @nogc @safe T cauchyCDF(T)(const T x)
if (isFloatingPoint!T);
Computes the Cauchy cumulative distribution function (CDF).
Parameters:
T x value to evaluate CDF
pure nothrow @nogc @safe T cauchyCDF(T)(const T x, const T location, const T scale)
if (isFloatingPoint!T);
Ditto, with location and scale parameters (by standardizing x).
Parameters:
T x value to evaluate CDF
T location location parameter
T scale scale parameter
Examples:
import mir.test: shouldApprox;

cauchyCDF(-3.0).shouldApprox == 0.1024164;
cauchyCDF(-2.0).shouldApprox == 0.1475836;
cauchyCDF(-1.0).shouldApprox == 0.25;
cauchyCDF(0.0).shouldApprox == 0.5;
cauchyCDF(1.0).shouldApprox == 0.75;
cauchyCDF(2.0).shouldApprox == 0.8524164;
cauchyCDF(3.0).shouldApprox == 0.8975836;

// Can include location/scale
cauchyCDF(-3.0, 1, 2).shouldApprox == 0.1475836;
cauchyCDF(-2.0, 1, 2).shouldApprox == 0.187167;
cauchyCDF(-1.0, 1, 2).shouldApprox == 0.25;
cauchyCDF(0.0, 1, 2).shouldApprox == 0.3524164;
cauchyCDF(1.0, 1, 2).shouldApprox == 0.5;
cauchyCDF(2.0, 1, 2).shouldApprox == 0.6475836;
cauchyCDF(3.0, 1, 2).shouldApprox == 0.75;
pure nothrow @nogc @safe T cauchyCCDF(T)(const T x)
if (isFloatingPoint!T);
Computes the Cauchy complementary cumulative distribution function (CCDF).
Parameters:
T x value to evaluate CCDF
pure nothrow @nogc @safe T cauchyCCDF(T)(const T x, const T location, const T scale)
if (isFloatingPoint!T);
Ditto, with location and scale parameters (by standardizing x).
Parameters:
T x value to evaluate CCDF
T location location parameter
T scale scale parameter
Examples:
import mir.test: shouldApprox;

cauchyCCDF(-3.0).shouldApprox == 0.8975836;
cauchyCCDF(-2.0).shouldApprox == 0.8524164;
cauchyCCDF(-1.0).shouldApprox == 0.75;
cauchyCCDF(0.0).shouldApprox == 0.5;
cauchyCCDF(1.0).shouldApprox == 0.25;
cauchyCCDF(2.0).shouldApprox == 0.1475836;
cauchyCCDF(3.0).shouldApprox == 0.1024164;

// Can include location/scale
cauchyCCDF(-3.0, 1, 2).shouldApprox == 0.8524164;
cauchyCCDF(-2.0, 1, 2).shouldApprox == 0.812833;
cauchyCCDF(-1.0, 1, 2).shouldApprox == 0.75;
cauchyCCDF(0.0, 1, 2).shouldApprox == 0.6475836;
cauchyCCDF(1.0, 1, 2).shouldApprox == 0.5;
cauchyCCDF(2.0, 1, 2).shouldApprox == 0.3524164;
cauchyCCDF(3.0, 1, 2).shouldApprox == 0.25;
pure nothrow @nogc @safe T cauchyInvCDF(T)(const T p)
if (isFloatingPoint!T);
Computes the Cauchy inverse cumulative distribution function (InvCDF).
Parameters:
T p value to evaluate InvCDF
pure nothrow @nogc @safe T cauchyInvCDF(T)(const T p, const T location, const T scale)
if (isFloatingPoint!T);
Ditto, with location and scale parameters.
Parameters:
T p value to evaluate InvCDF
T location location parameter
T scale scale parameter
Examples:
import mir.test: shouldApprox;

cauchyInvCDF(0.0).shouldApprox == -double.infinity;
cauchyInvCDF(0.1).shouldApprox == -3.077684;
cauchyInvCDF(0.2).shouldApprox == -1.376382;
cauchyInvCDF(0.3).shouldApprox == -0.7265425;
cauchyInvCDF(0.4).shouldApprox == -0.3249197;
cauchyInvCDF(0.5).shouldApprox == 0.0;
cauchyInvCDF(0.6).shouldApprox == 0.3249197;
cauchyInvCDF(0.7).shouldApprox == 0.7265425;
cauchyInvCDF(0.8).shouldApprox == 1.376382;
cauchyInvCDF(0.9).shouldApprox == 3.077684;
cauchyInvCDF(1.0).shouldApprox == double.infinity;

// Can include location/scale
cauchyInvCDF(0.2, 1, 2).shouldApprox == -1.752764;
cauchyInvCDF(0.4, 1, 2).shouldApprox == 0.3501606;
cauchyInvCDF(0.6, 1, 2).shouldApprox == 1.649839;
cauchyInvCDF(0.8, 1, 2).shouldApprox == 3.752764;
pure nothrow @nogc @safe T cauchyLPDF(T)(const T x)
if (isFloatingPoint!T);
Computes the Cauchy log probability density function (LPDF).
Parameters:
T x value to evaluate LPDF
pure nothrow @nogc @safe T cauchyLPDF(T)(const T x, const T location, const T scale)
if (isFloatingPoint!T);
Ditto, with location and scale parameters (by standardizing x).
Parameters:
T x value to evaluate LPDF
T location location parameter
T scale scale parameter
Examples:
import mir.math.common: log;
import mir.test: shouldApprox;

cauchyLPDF(-3.0).shouldApprox == log(0.03183099);
cauchyLPDF(-2.0).shouldApprox == log(0.06366198);
cauchyLPDF(-1.0).shouldApprox == log(0.1591549);
cauchyLPDF(0.0).shouldApprox == log(0.3183099);
cauchyLPDF(1.0).shouldApprox == log(0.1591549);
cauchyLPDF(2.0).shouldApprox == log(0.06366198);
cauchyLPDF(3.0).shouldApprox == log(0.03183099);

// Can include location/scale
cauchyLPDF(-3.0, 1, 2).shouldApprox == log(0.03183099);
cauchyLPDF(-2.0, 1, 2).shouldApprox == log(0.04897075);
cauchyLPDF(-1.0, 1, 2).shouldApprox == log(0.07957747);
cauchyLPDF(0.0, 1, 2).shouldApprox == log(0.127324);
cauchyLPDF(1.0, 1, 2).shouldApprox == log(0.1591549);
cauchyLPDF(2.0, 1, 2).shouldApprox == log(0.127324);
cauchyLPDF(3.0, 1, 2).shouldApprox == log(0.07957747);