private void AddEntropyResultItems(EntropyLogic pEntropyLogic, MatchCollection pMatchCollection, EntropyResult pEntropyResult) { foreach (Match m in pMatchCollection) { string value = m.Value; if (pEntropyLogic.Trim != string.Empty) { value = value.Trim(); } if (pEntropyLogic.NoEmpty && value == string.Empty) { continue; } EntropyItem it = pEntropyResult.ItemList.Find(x => x.Value == value); if (it == null) { pEntropyResult.ItemList.Add(new EntropyItem() { Value = value, Count = 1 }); } else { it.Count++; } pEntropyResult.SignCount++; } }
private void CalcItem(EntropyResult pEntropyResult, EntropyItem pEntropyItem) { pEntropyItem.P = (double)pEntropyItem.Count / pEntropyResult.SignCount; double pI = 1 / pEntropyItem.P; pEntropyItem.I = Math.Log(pI, 2); pEntropyResult.ShannonEntropy += pEntropyItem.P * pEntropyItem.I; }
private void SumItem(EntropyResult pEntropyResult, EntropyItem pEntropyItem) { EntropyItem it2 = pEntropyResult.ItemList.Find(x => x.Value == pEntropyItem.Value); if (it2 == null) { pEntropyResult.ItemList.Add(new EntropyItem() { Value = pEntropyItem.Value, Count = pEntropyItem.Count }); } else { it2.Count += pEntropyItem.Count; } }