/** * <summary> The entropyForDiscreteAttribute method takes an attributeIndex and creates an List of DiscreteDistribution. * Then loops through the distributions and calculates the total entropy.</summary> * * <param name="attributeIndex">Index of the attribute.</param> * <returns>Total entropy for the discrete attribute.</returns> */ private double EntropyForDiscreteAttribute(int attributeIndex) { var sum = 0.0; var distributions = _data.AttributeClassDistribution(attributeIndex); foreach (var distribution in distributions) { sum += (distribution.GetSum() / _data.Size()) * distribution.Entropy(); } return(sum); }