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

This module contains algorithms for the Logistic Distribution.
License:
Authors:
John Michael Hall
pure nothrow @nogc @safe T logisticPDF(T)(const T x)
if (isFloatingPoint!T);
Computes the Logistic probability density function (PDF).
Parameters:
T x value to evaluate PDF
pure nothrow @nogc @safe T logisticPDF(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;

logisticPDF(-2.0).shouldApprox == 0.1049936;
logisticPDF(-1.0).shouldApprox == 0.1966119;
logisticPDF(-0.5).shouldApprox == 0.2350037;
logisticPDF(0.0).shouldApprox == 0.25;
logisticPDF(0.5).shouldApprox == 0.2350037;
logisticPDF(1.0).shouldApprox == 0.1966119;
logisticPDF(2.0).shouldApprox == 0.1049936;

// Can also provide location/scale parameters
logisticPDF(-1.0, 2.0, 3.0).shouldApprox == 0.06553731;
logisticPDF(1.0, 2.0, 3.0).shouldApprox == 0.08106072;
logisticPDF(4.0, 2.0, 3.0).shouldApprox == 0.07471913;
pure nothrow @nogc @safe T logisticCDF(T)(const T x)
if (isFloatingPoint!T);
Computes the Logistic cumulative distribution function (CDF).
Parameters:
T x value to evaluate CDF
pure nothrow @nogc @safe T logisticCDF(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;

logisticCDF(-2.0).shouldApprox == 0.1192029;
logisticCDF(-1.0).shouldApprox == 0.2689414;
logisticCDF(-0.5).shouldApprox == 0.3775407;
logisticCDF(0.0).shouldApprox == 0.5;
logisticCDF(0.5).shouldApprox == 0.6224593;
logisticCDF(1.0).shouldApprox == 0.7310586;
logisticCDF(2.0).shouldApprox == 0.8807971;

// Can also provide location/scale parameters
logisticCDF(-1.0, 2.0, 3.0).shouldApprox == 0.2689414;
logisticCDF(1.0, 2.0, 3.0).shouldApprox == 0.4174298;
logisticCDF(4.0, 2.0, 3.0).shouldApprox == 0.6607564;
pure nothrow @nogc @safe T logisticCCDF(T)(const T x)
if (isFloatingPoint!T);
Computes the Logistic complementary cumulative distribution function (CCDF).
Parameters:
T x value to evaluate CCDF
pure nothrow @nogc @safe T logisticCCDF(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;

logisticCCDF(-2.0).shouldApprox == 0.8807971;
logisticCCDF(-1.0).shouldApprox == 0.7310586;
logisticCCDF(-0.5).shouldApprox == 0.6224593;
logisticCCDF(0.0).shouldApprox == 0.5;
logisticCCDF(0.5).shouldApprox == 0.3775407;
logisticCCDF(1.0).shouldApprox == 0.2689414;
logisticCCDF(2.0).shouldApprox == 0.1192029;

// Can also provide location/scale parameters
logisticCCDF(-1.0, 2.0, 3.0).shouldApprox == 0.7310586;
logisticCCDF(1.0, 2.0, 3.0).shouldApprox == 0.5825702;
logisticCCDF(4.0, 2.0, 3.0).shouldApprox == 0.3392436;
pure nothrow @nogc @safe T logisticInvCDF(T)(const T p)
if (isFloatingPoint!T);
Computes the Logistic inverse cumulative distribution function (InvCDF).
Parameters:
T p value to evaluate InvCDF
pure nothrow @nogc @safe T logisticInvCDF(T)(const T p, const T location, const T scale)
if (isFloatingPoint!T);
Ditto, with location and scale parameters (by standardizing x).
Parameters:
T p value to evaluate InvCDF
T location location parameter
T scale scale parameter
Examples:
import mir.test: shouldApprox;

logisticInvCDF(0.0).shouldApprox == -double.infinity;
logisticInvCDF(0.25).shouldApprox == -1.098612;
logisticInvCDF(0.5).shouldApprox == 0.0;
logisticInvCDF(0.75).shouldApprox == 1.098612;
logisticInvCDF(1.0).shouldApprox == double.infinity;

// Can also provide location/scale parameters
logisticInvCDF(0.2, 2, 3).shouldApprox == -2.158883;
logisticInvCDF(0.4, 2, 3).shouldApprox == 0.7836047;
logisticInvCDF(0.6, 2, 3).shouldApprox == 3.216395;
logisticInvCDF(0.8, 2, 3).shouldApprox == 6.158883;
pure nothrow @nogc @safe T logisticLPDF(T)(const T x)
if (isFloatingPoint!T);
Computes the Logistic log probability density function (LPDF).
Parameters:
T x value to evaluate LPDF
pure nothrow @nogc @safe T logisticLPDF(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;

logisticLPDF(-2.0).shouldApprox == log(0.1049936);
logisticLPDF(-1.0).shouldApprox == log(0.1966119);
logisticLPDF(-0.5).shouldApprox == log(0.2350037);
logisticLPDF(0.0).shouldApprox == log(0.25);
logisticLPDF(0.5).shouldApprox == log(0.2350037);
logisticLPDF(1.0).shouldApprox == log(0.1966119);
logisticLPDF(2.0).shouldApprox == log(0.1049936);

// Can also provide location/scale parameters
logisticLPDF(-1.0, 2.0, 3.0).shouldApprox == log(0.06553731);
logisticLPDF(1.0, 2.0, 3.0).shouldApprox == log(0.08106072);
logisticLPDF(4.0, 2.0, 3.0).shouldApprox == log(0.07471913);