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.categorical
This module contains algorithms for the Categorical Distribution.
License:
Authors:
John Michael Hall
- pure nothrow @nogc @safe T
categoricalPMF
(T)(const size_tx
, const Slice!(T*, 1)p
)
if (isFloatingPoint!T); - Computes the Categorical probability mass function (PMF).Parameters:
size_t x
value to evaluate PMF Slice!(T*, 1) p
slice containing the probability associated with the Categorical Distribution See Also:Examples:import mir.ndslice.slice: sliced; import mir.test: shouldApprox; static immutable x = [0.1, 0.5, 0.4]; auto p = x.sliced; 0.categoricalPMF(p).shouldApprox == 0.1; 1.categoricalPMF(p).shouldApprox == 0.5; 2.categoricalPMF(p).shouldApprox == 0.4;
- pure nothrow @nogc @safe T
categoricalCDF
(T)(const size_tx
, const Slice!(T*, 1)p
)
if (isFloatingPoint!T); - Computes the Categorical cumulative distribution function (CDF).Parameters:
size_t x
value to evaluate CDF Slice!(T*, 1) p
slice containing the probability associated with the Categorical Distribution See Also:Examples:import mir.ndslice.slice: sliced; import mir.test: shouldApprox; static immutable x = [0.1, 0.5, 0.4]; auto p = x.sliced; 0.categoricalCDF(p).shouldApprox == 0.1; 1.categoricalCDF(p).shouldApprox == 0.6; 2.categoricalCDF(p).shouldApprox == 1.0;
- pure nothrow @nogc @safe T
categoricalCCDF
(T)(const size_tx
, const Slice!(T*, 1)p
)
if (isFloatingPoint!T); - Computes the Categorical complementary cumulative distribution function (CCDF).Parameters:
size_t x
value to evaluate CCDF Slice!(T*, 1) p
slice containing the probability associated with the Categorical Distribution See Also:Examples:import mir.ndslice.slice: sliced; import mir.test: shouldApprox; static immutable x = [0.1, 0.5, 0.4]; auto p = x.sliced; 0.categoricalCCDF(p).shouldApprox == 1.0; 1.categoricalCCDF(p).shouldApprox == 0.9; 2.categoricalCCDF(p).shouldApprox == 0.4;
- pure nothrow @nogc @safe size_t
categoricalInvCDF
(T)(const Tq
, const Slice!(T*, 1)p
)
if (isFloatingPoint!T); - Computes the Categorical inverse cumulative distribution function (InvCDF).Parameters:
T q
value to evaluate InvCDF Slice!(T*, 1) p
slice containing the probability associated with the Categorical Distribution See Also:Examples:import mir.ndslice.slice: sliced; import mir.test: should; static immutable x = [0.1, 0.5, 0.4]; auto p = x.sliced; categoricalInvCDF(0.0, p).should == 0; categoricalInvCDF(0.1, p).should == 0; categoricalInvCDF(0.2, p).should == 1; categoricalInvCDF(0.3, p).should == 1; categoricalInvCDF(0.4, p).should == 1; categoricalInvCDF(0.5, p).should == 1; categoricalInvCDF(0.6, p).should == 1; categoricalInvCDF(0.7, p).should == 2; categoricalInvCDF(0.8, p).should == 2; categoricalInvCDF(0.9, p).should == 2; categoricalInvCDF(1.0, p).should == 2;
- pure nothrow @nogc @safe T
categoricalLPMF
(T)(const size_tx
, const Slice!(T*, 1)p
)
if (isFloatingPoint!T); - Computes the Categorical log probability mass function (LPMF).Parameters:
size_t x
value to evaluate LPMF Slice!(T*, 1) p
slice containing the probability associated with the Categorical Distribution See Also:Examples:import mir.math.common: log; import mir.ndslice.slice: sliced; import mir.test: shouldApprox; static immutable x = [0.1, 0.5, 0.4]; auto p = x.sliced; 0.categoricalLPMF(p).shouldApprox == log(0.1); 1.categoricalLPMF(p).shouldApprox == log(0.5); 2.categoricalLPMF(p).shouldApprox == log(0.4);
Copyright © 2016-2023 by Ilya Yaroshenko | Page generated by
Ddoc on Sun Feb 12 23:00:02 2023