The OpenD Programming Language

categoricalCCDF

Computes the Categorical complementary cumulative distribution function (CCDF).

  1. sumType!(Slice!(Iterator, 1, kind)) categoricalCCDF(size_t x, Slice!(Iterator, 1, kind) p)
  2. T categoricalCCDF(size_t x, T[] p)
    @safe pure nothrow @nogc
    T
    categoricalCCDF
    (
    T
    )
    (
    const size_t x
    ,
    scope const T[] p...
    )
    if (
    isFloatingPoint!T
    )

Parameters

x size_t

value to evaluate CCDF

p T[]

slice containing the probability associated with the Categorical Distribution

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;

Can also use dynamic array

import mir.test: shouldApprox;

double[] p = [0.1, 0.5, 0.4];

0.categoricalCCDF(p).shouldApprox == 1.0;
1.categoricalCCDF(p).shouldApprox == 0.9;
2.categoricalCCDF(p).shouldApprox == 0.4;

See Also

Meta