private static void ChekcLogic(EntropyResult er1, EntropyResult er2) { Assert.IsTrue(er1.Logic.Name == er2.Logic.Name); Assert.IsTrue(er1.Logic.Trim == er2.Logic.Trim); Assert.IsTrue(er1.Logic.NoEmpty == er2.Logic.NoEmpty); Assert.IsTrue(er1.Logic.RegexList.Count == er2.Logic.RegexList.Count); }
private static void CheckEntropyData(EntropyResult er2, EntropyItem ei1) { EntropyItem ei2 = er2.ItemList.Find(x => x.Value == ei1.Value); Assert.IsTrue(ei1.Count == ei2.Count); Assert.IsTrue(ei1.P == ei2.P); Assert.IsTrue(ei1.I == ei2.I); }
private static void ChekcEntropyData(EntropyResult er1, EntropyResult er2) { Assert.IsTrue(er1.ShannonEntropy == er2.ShannonEntropy); Assert.IsTrue(er1.I == er2.I); Assert.IsTrue(er1.Hmax == er2.Hmax); Assert.IsTrue(er1.SignCount == er2.SignCount); Assert.IsTrue(er1.DifferentSignsCount == er2.DifferentSignsCount); Assert.IsTrue(er1.ItemList.Count == er2.ItemList.Count); }
public void TestEntropy_20PM_01sec() { var start = new TimeSpan(0, 6, 0, 0); var checkPointRate = new TimeSpan(0, 0, 0, 0, 100); EntropyResult result = CalculateEntropy(checkPointRate); Assert.AreEqual(0.94022441944856294, result.EntropyValue); }
public void TestEntropy_20PM_1sec() { var start = new TimeSpan(0, 6, 0, 0); var checkPointRate = new TimeSpan(0, 0, 0, 1); EntropyResult result = CalculateEntropy(checkPointRate); Assert.AreEqual(0.94035920104979653, result.EntropyValue); }
public void TestEntropy_20PM_1minute() { var start = new TimeSpan(0, 6, 0, 0); var checkPointRate = new TimeSpan(0, 0, 1, 0); EntropyResult result = CalculateEntropy(checkPointRate); Assert.AreEqual(0.93538061199532574, result.EntropyValue); }
public void TestEntropy_20PM_1hour() { var start = new TimeSpan(0, 6, 0, 0); var checkPointRate = new TimeSpan(0, 1, 0, 0); EntropyResult result = CalculateEntropy(checkPointRate); Assert.AreEqual(0.94681062804085736, result.EntropyValue); }
private static void CheckLogicItem(EntropyResult er1, EntropyResult er2, int j) { RegEx re1 = er1.Logic.RegexList[j]; RegEx re2 = er2.Logic.RegexList[j]; Assert.IsTrue(re1.Pattern == re2.Pattern); Assert.IsTrue(re1.RegexOptions == re2.RegexOptions); Assert.IsTrue(re1.Replace == re2.Replace); Assert.IsTrue(re1.ToLower == re2.ToLower); }
public void SaveSnapshotsEntropy(Person person, string toFilePath) { if (String.IsNullOrEmpty(toFilePath)) { toFilePath = String.Concat(person.Id, "outputSnapshotsEntropy.csv"); } EntropyResult result = calculationService.CalculateEntropy(person); entropyService.Save(result, toFilePath); }
public void Save(EntropyResult result, string toFilePath) { using (var writer = new StreamWriter(toFilePath)) { writer.WriteLine(String.Concat("EntropyValue", ": ", result.EntropyValue)); foreach (var record in result.ActivityProbability) { writer.WriteLine(String.Concat(record.Key, " - ", record.Value)); } } }
private static void CheckContentItem(List <EntropyResult> erl1, EntropyResult er1) { EntropyResult er2 = erl1.Find(x => x.Logic.Name == er1.Logic.Name); ChekcLogic(er1, er2); for (int j = 0; j < er1.Logic.RegexList.Count; j++) { CheckLogicItem(er1, er2, j); } ChekcEntropyData(er1, er2); foreach (EntropyItem ei1 in er1.ItemList) { CheckEntropyData(er2, ei1); } }
public void TestEntropy_Day3_01sec() { var start = new DateTime(2007, 10, 27, 6, 0, 0); var stop = new DateTime(2007, 10, 28, 6, 0, 0); var checkPointRate = new TimeSpan(0, 0, 0, 0, 100); var results = new List <double>(); EntropyResult result = CalculateEntropy(start, stop, checkPointRate); results.Add(result.EntropyValue); SaveData(String.Format(entropyPath), results); Assert.AreEqual(1, results.Count); Assert.AreEqual(0.84262640775174968, results[0]); }
public EntropyResult CalculateEntropy(Person person) { if (person.IsEntropyKnown) { return(person.EntropyResult); } if (!person.IsSnapshotsKnown) { person.Snapshots = CalculateSnapshots(person); } var entropy = new Entropy(); EntropyResult result = entropy.CalculateShannonEntropy(person.Snapshots, alphabet.GetAlphabet()); person.EntropyResult = result; person.IsEntropyKnown = true; return(result); }
public void TestEntropy_Day3Shift_1sec() { var shiftedStart = new DateTime(2007, 10, 27, 6, 0, 0); var shiftedStop = new DateTime(2007, 10, 28, 6, 0, 0); var shiftBy = new TimeSpan(0, 0, 0, 0, 100); var checkPointRate = new TimeSpan(0, 0, 1, 0); //var fullStop = shiftedStop; var fullStop = new DateTime(2007, 10, 27, 6, 1, 0); var results = new List <double>(); while (shiftedStart < fullStop) { EntropyResult result = CalculateEntropy(shiftedStart, shiftedStop, checkPointRate); results.Add(result.EntropyValue); shiftedStart = shiftedStart.Add(shiftBy); shiftedStop = shiftedStop.Add(shiftBy); } SaveData(String.Format(entropyPath), results); Assert.AreEqual(600, results.Count); }
public void TestEntropyResult() { er = new EntropyResult(); CheckEntropyDefaultData(); }