value to evaluate PMF
slice containing the probability associated with the Categorical Distribution
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;
Can also use dynamic array
import mir.test: shouldApprox; double[] p = [0.1, 0.5, 0.4]; 0.categoricalPMF(p).shouldApprox == 0.1; 1.categoricalPMF(p).shouldApprox == 0.5; 2.categoricalPMF(p).shouldApprox == 0.4;
import mir.math.sum: sum; import mir.ndslice.slice: sliced; import mir.test: shouldApprox; static immutable x = [1.0, 5, 4]; auto p = x.sliced; auto q = p / sum(p); 0.categoricalPMF(q).shouldApprox == 0.1; 1.categoricalPMF(q).shouldApprox == 0.5; 2.categoricalPMF(q).shouldApprox == 0.4;
Computes the Categorical probability mass function (PMF).