public double GetEntropy() { DoubleHistogram histogram = new DoubleHistogram(_items, _binCnt); var dataCntInBin = histogram.GetDataCountInBin(); return(new DiscreteEntropy <int>(Util.GetDictionary(dataCntInBin), _logBase).GetEntropy()); }
public double GetEntropy() { var xlistLen = _xlist.Count(); DoubleHistogram[] histograms = new DoubleHistogram[xlistLen]; for (int i = 0; i < xlistLen; i++) { histograms[i] = new DoubleHistogram(_xlist.ElementAt(i), _binCntList.ElementAt(i)); } if (xlistLen == 2) { Dictionary <Tuple <int, int>, int> countDict = new Dictionary <Tuple <int, int>, int>(); for (int j = 0; j < _xLen; j++) { var tuple = new Tuple <int, int>(histograms[0].GetBinIndex(_xlist.ElementAt(0).ElementAt(j)), histograms[1].GetBinIndex(_xlist.ElementAt(1).ElementAt(j))); if (!countDict.ContainsKey(tuple)) { countDict.Add(tuple, 1); } else { countDict[tuple]++; } } return(new DiscreteEntropy <Tuple <int, int> >(countDict, _logBase).GetEntropy()); } else if (xlistLen == 3) { Dictionary <Tuple <int, int, int>, int> countDict = new Dictionary <Tuple <int, int, int>, int>(); for (int j = 0; j < _xLen; j++) { var tuple = new Tuple <int, int, int>(histograms[0].GetBinIndex(_xlist.ElementAt(0).ElementAt(j)), histograms[1].GetBinIndex(_xlist.ElementAt(1).ElementAt(j)), histograms[2].GetBinIndex(_xlist.ElementAt(2).ElementAt(j))); if (!countDict.ContainsKey(tuple)) { countDict.Add(tuple, 1); } else { countDict[tuple]++; } } return(new DiscreteEntropy <Tuple <int, int, int> >(countDict, _logBase).GetEntropy()); } else { throw new NotImplementedException(); } }