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

This module contains algorithms for the Log-normal Distribution.
License:
Authors:
John Michael Hall
pure nothrow @nogc @safe T logNormalPDF(T)(const T x)
if (isFloatingPoint!T);
Computes the Log-normal probability density function (PDF).
Parameters:
T x value to evaluate PDF
pure nothrow @nogc @safe T logNormalPDF(T)(const T x, 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 mean location parameter
T stdDev scale parameter
Examples:
import mir.test: shouldApprox;

logNormalPDF(1.0).shouldApprox == 0.3989423;
logNormalPDF(2.0).shouldApprox == 0.156874;
logNormalPDF(3.0).shouldApprox == 0.07272826;

// Can include location/scale
logNormalPDF(1.0, 1, 2).shouldApprox == 0.1760327;
logNormalPDF(2.0, 1, 2).shouldApprox == 0.09856858;
logNormalPDF(3.0, 1, 2).shouldApprox == 0.06640961;
pure nothrow @nogc @safe T logNormalCDF(T)(const T x)
if (isFloatingPoint!T);
Computes the Log-normal cumulative distribution function (CDF).
Parameters:
T x value to evaluate CDF
pure nothrow @nogc @safe T logNormalCDF(T)(const T x, 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 mean location parameter
T stdDev scale parameter
Examples:
import mir.test: shouldApprox;

logNormalCDF(0.0).shouldApprox == 0;
logNormalCDF(1.0).shouldApprox == 0.5;
logNormalCDF(2.0).shouldApprox == 0.7558914;
logNormalCDF(3.0).shouldApprox == 0.8640314;

// Can include location/scale
logNormalCDF(0.0, 1, 2).shouldApprox == 0;
logNormalCDF(1.0, 1, 2).shouldApprox == 0.3085375;
logNormalCDF(2.0, 1, 2).shouldApprox == 0.439031;
logNormalCDF(3.0, 1, 2).shouldApprox == 0.5196623;
pure nothrow @nogc @safe T logNormalCCDF(T)(const T x)
if (isFloatingPoint!T);
Computes the Student's t complementary cumulative distribution function (CCDF).
Parameters:
T x value to evaluate CCDF
pure nothrow @nogc @safe T logNormalCCDF(T)(const T x, 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 mean location parameter
T stdDev scale parameter
Examples:
import mir.test: shouldApprox;

logNormalCCDF(0.0).shouldApprox == 1;
logNormalCCDF(1.0).shouldApprox == 0.5;
logNormalCCDF(2.0).shouldApprox == 0.2441086;
logNormalCCDF(3.0).shouldApprox == 0.1359686;

// Can include location/scale
logNormalCCDF(0.0, 1, 2).shouldApprox == 1;
logNormalCCDF(1.0, 1, 2).shouldApprox == 0.6914625;
logNormalCCDF(2.0, 1, 2).shouldApprox == 0.560969;
logNormalCCDF(3.0, 1, 2).shouldApprox == 0.4803377;
pure nothrow @nogc @safe T logNormalInvCDF(T)(const T p)
if (isFloatingPoint!T);
Computes the Log-normal inverse cumulative distribution function (InvCDF).
Parameters:
T p value to evaluate InvCDF
pure nothrow @nogc @safe T logNormalInvCDF(T)(const T p, 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 mean location parameter
T stdDev scale parameter
Examples:
import mir.test: shouldApprox;

logNormalInvCDF(0.00).shouldApprox == 0;
logNormalInvCDF(0.25).shouldApprox == 0.5094163;
logNormalInvCDF(0.50).shouldApprox == 1;
logNormalInvCDF(0.75).shouldApprox == 1.963031;
logNormalInvCDF(1.00).shouldApprox == double.infinity;

// Can include location/scale
logNormalInvCDF(0.00, 1, 2).shouldApprox == 0;
logNormalInvCDF(0.25, 1, 2).shouldApprox == 0.7054076;
logNormalInvCDF(0.50, 1, 2).shouldApprox == 2.718282;
logNormalInvCDF(0.75, 1, 2).shouldApprox == 10.47487;
logNormalInvCDF(1.00, 1, 2).shouldApprox == double.infinity;
pure nothrow @nogc @safe T logNormalLPDF(T)(const T x)
if (isFloatingPoint!T);
Computes the Log-normal log probability density function (LPDF).
Parameters:
T x value to evaluate LPDF
pure nothrow @nogc @safe T logNormalLPDF(T)(const T x, 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 mean location parameter
T stdDev scale parameter
Examples:
import mir.math.common: log;
import mir.test: shouldApprox;

logNormalLPDF(1.0).shouldApprox == log(0.3989423);
logNormalLPDF(2.0).shouldApprox == log(0.156874);
logNormalLPDF(3.0).shouldApprox == log(0.07272826);

// Can include location/scale
logNormalLPDF(1.0, 1, 2).shouldApprox == log(0.1760327);
logNormalLPDF(2.0, 1, 2).shouldApprox == log(0.09856858);
logNormalLPDF(3.0, 1, 2).shouldApprox == log(0.06640961);