entropy

Calculates the joint entropy of a set of observations. Each input range represents a vector of observations. If only one range is given, this reduces to the plain old entropy. Input range must have a length.

Note: This function specializes if ElementType!(T) is a byte, ubyte, or char, resulting in a much faster entropy calculation. When possible, try to provide data in the form of a byte, ubyte, or char.

double
entropy
(
T
)
()
if (
isIterable!(T)
)

Examples

1 int[] foo = [1, 1, 1, 2, 2, 2, 3, 3, 3];
2 double entropyFoo = entropy(foo);  // Plain old entropy of foo.
3 assert(approxEqual(entropyFoo, log2(3)));
4 int[] bar = [1, 2, 3, 1, 2, 3, 1, 2, 3];
5 double HFooBar = entropy(joint(foo, bar));  // Joint entropy of foo and bar.
6 assert(approxEqual(HFooBar, log2(9)));

Meta