int[] foo = [1, 1, 1, 2, 2, 2, 3, 3, 3]; double entropyFoo = entropy(foo); // Plain old entropy of foo. assert(approxEqual(entropyFoo, log2(3))); int[] bar = [1, 2, 3, 1, 2, 3, 1, 2, 3]; double HFooBar = entropy(joint(foo, bar)); // Joint entropy of foo and bar. assert(approxEqual(HFooBar, log2(9)));
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.