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

This module contains algorithms for the Weibull Distribution.
License:
Authors:
John Michael Hall
pure nothrow @nogc @safe T weibullPDF(T)(const T x, const T shape, const T scale = 1)
if (isFloatingPoint!T);
Computes the Weibull probability density function (PDF).
Parameters:
T x value to evaluate PDF
T shape shape parameter
T scale scale parameter
Examples:
import mir.test: shouldApprox;

0.0.weibullPDF(3.0).shouldApprox == 0;
0.5.weibullPDF(3.0).shouldApprox == 0.6618727;
1.0.weibullPDF(3.0).shouldApprox == 1.103638;
1.5.weibullPDF(3.0).shouldApprox == 0.2309723;

// Can also provide scale parameter
0.5.weibullPDF(2.0, 3.0).shouldApprox == 0.1080672;
1.0.weibullPDF(2.0, 3.0).shouldApprox == 0.1988532;
1.5.weibullPDF(2.0, 3.0).shouldApprox == 0.2596003;
pure nothrow @nogc @safe T weibullCDF(T)(const T x, const T shape, const T scale = 1)
if (isFloatingPoint!T);
Computes the Weibull cumulative distribution function (CDF).
Parameters:
T x value to evaluate CDF
T shape shape parameter
T scale scale parameter
Examples:
import mir.test: shouldApprox;

0.0.weibullCDF(3.0).shouldApprox == 0;
0.5.weibullCDF(3.0).shouldApprox == 0.1175031;
1.0.weibullCDF(3.0).shouldApprox == 0.6321206;
1.5.weibullCDF(3.0).shouldApprox == 0.9657819;

// Can also provide scale parameter
0.5.weibullCDF(2.0, 3.0).shouldApprox == 0.02739552;
1.0.weibullCDF(2.0, 3.0).shouldApprox == 0.1051607;
1.5.weibullCDF(2.0, 3.0).shouldApprox == 0.2211992;
pure nothrow @nogc @safe T weibullCCDF(T)(const T x, const T shape, const T scale = 1)
if (isFloatingPoint!T);
Computes the Weibull complementary cumulative distribution function (CCDF).
Parameters:
T x value to evaluate CCDF
T shape shape parameter
T scale scale parameter
Examples:
import mir.test: shouldApprox;

0.0.weibullCCDF(3.0).shouldApprox == 1;
0.5.weibullCCDF(3.0).shouldApprox == 0.8824969;
1.0.weibullCCDF(3.0).shouldApprox == 0.3678794;
1.5.weibullCCDF(3.0).shouldApprox == 0.03421812;

// Can also provide scale parameter
0.5.weibullCCDF(2.0, 3.0).shouldApprox == 0.9726045;
1.0.weibullCCDF(2.0, 3.0).shouldApprox == 0.8948393;
1.5.weibullCCDF(2.0, 3.0).shouldApprox == 0.7788008;
pure nothrow @nogc @safe T weibullInvCDF(T)(const T p, const T shape, const T scale = 1)
if (isFloatingPoint!T);
Computes the Weibull inverse cumulative distribution function (InvCDF).
Parameters:
T p value to evaluate InvCDF
T shape shape parameter
T scale scale parameter
Examples:
import mir.test: shouldApprox;

weibullInvCDF(0.0, 3).shouldApprox == 0.0;
weibullInvCDF(0.25, 3).shouldApprox == 0.6601424;
weibullInvCDF(0.5, 3).shouldApprox == 0.884997;
weibullInvCDF(0.75, 3).shouldApprox == 1.115026;
weibullInvCDF(1.0, 3).shouldApprox == double.infinity;

// Can also provide scale parameter
weibullInvCDF(0.2, 2, 3).shouldApprox == 1.417142;
weibullInvCDF(0.4, 2, 3).shouldApprox == 2.144162;
weibullInvCDF(0.6, 2, 3).shouldApprox == 2.871692;
weibullInvCDF(0.8, 2, 3).shouldApprox == 3.805909;
pure nothrow @nogc @safe T weibullLPDF(T)(const T x, const T shape, const T scale = 1)
if (isFloatingPoint!T);
Computes the Weibull log probability density function (LPDF).
Parameters:
T x value to evaluate LPDF
T shape shape parameter
T scale scale parameter
Examples:
import mir.math.common: log;
import mir.test: shouldApprox;

0.0.weibullLPDF(3.0).shouldApprox == log(0.0);
0.5.weibullLPDF(3.0).shouldApprox == log(0.6618727);
1.0.weibullLPDF(3.0).shouldApprox == log(1.103638);
1.5.weibullLPDF(3.0).shouldApprox == log(0.2309723);

// Can also provide scale parameter
0.5.weibullLPDF(2.0, 3.0).shouldApprox == log(0.1080672);
1.0.weibullLPDF(2.0, 3.0).shouldApprox == log(0.1988532);
1.5.weibullLPDF(2.0, 3.0).shouldApprox == log(0.2596003);