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

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

0.0.rayleighPDF.shouldApprox == 0.0;
0.5.rayleighPDF.shouldApprox == 0.4412485;
1.0.rayleighPDF.shouldApprox == 0.6065307;
2.0.rayleighPDF.shouldApprox == 0.2706706;

// Can also provide scale parameter
0.5.rayleighPDF(2.0).shouldApprox == 0.1211541;
1.0.rayleighPDF(2.0).shouldApprox == 0.2206242;
4.0.rayleighPDF(2.0).shouldApprox == 0.1353353;
pure nothrow @nogc @safe T rayleighCDF(T)(const T x)
if (isFloatingPoint!T);
Computes the Rayleigh cumulative distribution function (CDF).
Parameters:
T x value to evaluate CDF
T rayleighCDF(T)(const T x, const T scale)
if (isFloatingPoint!T);
Ditto, with scale parameter.
Parameters:
T x value to evaluate CDF
T scale scale parameter
Examples:
import mir.test: shouldApprox;

0.0.rayleighCDF.shouldApprox == 0.0;
0.5.rayleighCDF.shouldApprox == 0.1175031;
1.0.rayleighCDF.shouldApprox == 0.3934693;
2.0.rayleighCDF.shouldApprox == 0.8646647;

// Can also provide scale parameter
0.5.rayleighCDF(2.0).shouldApprox == 0.03076677;
1.0.rayleighCDF(2.0).shouldApprox == 0.1175031;
4.0.rayleighCDF(2.0).shouldApprox == 0.8646647;
pure nothrow @nogc @safe T rayleighCCDF(T)(const T x)
if (isFloatingPoint!T);
Computes the Rayleigh complementary cumulative distribution function (CCDF).
Parameters:
T x value to evaluate CCDF
pure nothrow @nogc @safe T rayleighCCDF(T)(const T x, const T scale)
if (isFloatingPoint!T);
Ditto, with scale parameter.
Parameters:
T x value to evaluate CCDF
T scale scale parameter
Examples:
import mir.test: shouldApprox;

0.0.rayleighCCDF.shouldApprox == 1.0;
0.5.rayleighCCDF.shouldApprox == 0.8824969;
1.0.rayleighCCDF.shouldApprox == 0.6065307;
2.0.rayleighCCDF.shouldApprox == 0.1353353;

// Can also provide scale parameter
0.5.rayleighCCDF(2.0).shouldApprox == 0.9692332;
1.0.rayleighCCDF(2.0).shouldApprox == 0.8824969;
4.0.rayleighCCDF(2.0).shouldApprox == 0.1353353;
pure nothrow @nogc @safe T rayleighInvCDF(T)(const T p)
if (isFloatingPoint!T);
Computes the Rayleigh inverse cumulative distribution function (InvCDF).
Parameters:
T p value to evaluate InvCDF
pure nothrow @nogc @safe T rayleighInvCDF(T)(const T p, const T scale)
if (isFloatingPoint!T);
Ditto, with scale parameter.
Parameters:
T p value to evaluate InvCDF
T scale scale parameter
Examples:
import mir.test: shouldApprox;

rayleighInvCDF(0.0).shouldApprox == 0.0;
rayleighInvCDF(0.25).shouldApprox == 0.7585276;
rayleighInvCDF(0.5).shouldApprox == 1.17741;
rayleighInvCDF(0.75).shouldApprox == 1.665109;
rayleighInvCDF(1.0).shouldApprox == double.infinity;

// Can also provide scale parameter
rayleighInvCDF(0.2, 2).shouldApprox == 1.336094;
rayleighInvCDF(0.4, 2).shouldApprox == 2.021535;
rayleighInvCDF(0.6, 2).shouldApprox == 2.707457;
rayleighInvCDF(0.8, 2).shouldApprox == 3.588245;
pure nothrow @nogc @safe T rayleighLPDF(T)(const T x)
if (isFloatingPoint!T);
Computes the Rayleigh log probability density function (LPDF).
Parameters:
T x value to evaluate LPDF
pure nothrow @nogc @safe T rayleighLPDF(T)(const T x, const T scale)
if (isFloatingPoint!T);
Ditto, with scale parameter.
Parameters:
T x value to evaluate LPDF
T scale scale parameter
Examples:
import mir.math.common: log;
import mir.test: shouldApprox;

0.0.rayleighLPDF.shouldApprox == -double.infinity;
0.5.rayleighLPDF.shouldApprox == log(0.4412485);
1.0.rayleighLPDF.shouldApprox == log(0.6065307);
2.0.rayleighLPDF.shouldApprox == log(0.2706706);

// Can also provide scale parameter
0.5.rayleighLPDF(2.0).shouldApprox == log(0.1211541);
1.0.rayleighLPDF(2.0).shouldApprox == log(0.2206242);
4.0.rayleighLPDF(2.0).shouldApprox == log(0.1353353);