The OpenD Programming Language

entropyCounts

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

double
entropyCounts
(
T
)
()

Examples

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

Meta