entropyCounts

This function calculates the Shannon entropy of a forward range that is treated as frequency counts of a set of discrete observations.

  1. double entropyCounts(T data)
    double
    entropyCounts
    (
    T
    )
    ()
    if (
    isForwardRange!(T) &&
    )
  2. double entropyCounts(T data, double n)

Examples

double uniform3 = entropyCounts([4, 4, 4]);
assert(approxEqual(uniform3, log2(3)));
double uniform4 = entropyCounts([5, 5, 5, 5]);
assert(approxEqual(uniform4, 2));

Meta