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.laplace
This module contains algorithms for the Laplace Distribution.
License:
Authors:
John Michael Hall
- pure nothrow @nogc @safe T
laplacePDF
(T)(const Tx
)
if (isFloatingPoint!T); - Computes the Laplace probability density function (PDF).Parameters:
T x
value to evaluate PDF See Also: - pure nothrow @nogc @safe T
laplacePDF
(T)(const Tx
, const Tlocation
, const Tscale
)
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; laplacePDF(-2.0).shouldApprox == 0.06766764; laplacePDF(-1.0).shouldApprox == 0.1839397; laplacePDF(-0.5).shouldApprox == 0.3032653; laplacePDF(0.0).shouldApprox == 0.5; laplacePDF(0.5).shouldApprox == 0.3032653; laplacePDF(1.0).shouldApprox == 0.1839397; laplacePDF(2.0).shouldApprox == 0.06766764; // Can also provide location/scale parameters laplacePDF(-1.0, 2.0, 3.0).shouldApprox == 0.06131324; laplacePDF(1.0, 2.0, 3.0).shouldApprox == 0.1194219; laplacePDF(4.0, 2.0, 3.0).shouldApprox == 0.08556952;
- pure nothrow @nogc @safe T
laplaceCDF
(T)(const Tx
)
if (isFloatingPoint!T); - Computes the Laplace cumulative distribution function (CDF).Parameters:
T x
value to evaluate CDF See Also: - pure nothrow @nogc @safe T
laplaceCDF
(T)(const Tx
, const Tlocation
, const Tscale
)
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; laplaceCDF(-2.0).shouldApprox == 0.06766764; laplaceCDF(-1.0).shouldApprox == 0.1839397; laplaceCDF(-0.5).shouldApprox == 0.3032653; laplaceCDF(0.0).shouldApprox == 0.5; laplaceCDF(0.5).shouldApprox == 0.6967347; laplaceCDF(1.0).shouldApprox == 0.8160603; laplaceCDF(2.0).shouldApprox == 0.9323324; // Can also provide location/scale parameters laplaceCDF(-1.0, 2.0, 3.0).shouldApprox == 0.1839397; laplaceCDF(1.0, 2.0, 3.0).shouldApprox == 0.3582657; laplaceCDF(4.0, 2.0, 3.0).shouldApprox == 0.7432914;
- pure nothrow @nogc @safe T
laplaceCCDF
(T)(const Tx
)
if (isFloatingPoint!T); - Computes the Laplace complementary cumulative distribution function (CCDF).Parameters:
T x
value to evaluate CCDF See Also: - T
laplaceCCDF
(T)(const Tx
, const Tlocation
, const Tscale
)
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; laplaceCCDF(-2.0).shouldApprox == 0.9323324; laplaceCCDF(-1.0).shouldApprox == 0.8160603; laplaceCCDF(-0.5).shouldApprox == 0.6967347; laplaceCCDF(0.0).shouldApprox == 0.5; laplaceCCDF(0.5).shouldApprox == 0.3032653; laplaceCCDF(1.0).shouldApprox == 0.1839397; laplaceCCDF(2.0).shouldApprox == 0.06766764; // Can also provide location/scale parameters laplaceCCDF(-1.0, 2.0, 3.0).shouldApprox == 0.8160603; laplaceCCDF(1.0, 2.0, 3.0).shouldApprox == 0.6417343; laplaceCCDF(4.0, 2.0, 3.0).shouldApprox == 0.2567086;
- pure nothrow @nogc @safe T
laplaceInvCDF
(T)(const Tp
)
if (isFloatingPoint!T); - Computes the Laplace inverse cumulative distribution function (InvCDF).Parameters:
T p
value to evaluate InvCDF See Also: - T
laplaceInvCDF
(T)(const Tp
, const Tlocation
, const Tscale
)
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 See Also:Examples:import mir.test: shouldApprox; laplaceInvCDF(0.0).shouldApprox == -double.infinity; laplaceInvCDF(0.25).shouldApprox == -0.6931472; laplaceInvCDF(0.5).shouldApprox == 0.0; laplaceInvCDF(0.75).shouldApprox == 0.6931472; laplaceInvCDF(1.0).shouldApprox == double.infinity; // Can also provide location/scale parameters laplaceInvCDF(0.2, 2, 3).shouldApprox == -0.7488722; laplaceInvCDF(0.4, 2, 3).shouldApprox == 1.330569; laplaceInvCDF(0.6, 2, 3).shouldApprox == 2.669431; laplaceInvCDF(0.8, 2, 3).shouldApprox == 4.748872;
- pure nothrow @nogc @safe T
laplaceLPDF
(T)(const Tx
)
if (isFloatingPoint!T); - Computes the Laplace log probability density function (LPDF).Parameters:
T x
value to evaluate LPDF See Also: - T
laplaceLPDF
(T)(const Tx
, const Tlocation
, const Tscale
)
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 See Also:Examples:import mir.math.common: log; import mir.test: shouldApprox; laplaceLPDF(-2.0).shouldApprox == log(0.06766764); laplaceLPDF(-1.0).shouldApprox == log(0.1839397); laplaceLPDF(-0.5).shouldApprox == log(0.3032653); laplaceLPDF(0.0).shouldApprox == log(0.5); laplaceLPDF(0.5).shouldApprox == log(0.3032653); laplaceLPDF(1.0).shouldApprox == log(0.1839397); laplaceLPDF(2.0).shouldApprox == log(0.06766764); // Can also provide location/scale parameters laplaceLPDF(-1.0, 2.0, 3.0).shouldApprox == log(0.06131324); laplaceLPDF(1.0, 2.0, 3.0).shouldApprox == log(0.1194219); laplaceLPDF(4.0, 2.0, 3.0).shouldApprox == log(0.08556952);
Copyright © 2016-2023 by Ilya Yaroshenko | Page generated by
Ddoc on Wed Oct 18 12:23:06 2023