Esempio n. 1
0
 private void _cnx_PingRequested(ITransport transport, uint sequence)
 {
     IList<uint> outstanding;
     if (!outstandingPings.TryGetValue(transport, out outstanding))
     {
         outstandingPings[transport] = outstanding = new List<uint>();
     }
     outstanding.Add(sequence);
     if (!statistics.ContainsKey(transport))
     {
         statistics[transport] = new StatisticalMoments();
     }
 }
Esempio n. 2
0
 private void _cnx_PingReceived(ITransport transport, uint sequence, TimeSpan roundtrip)
 {
     IList<uint> outstanding;
     if (!outstandingPings.TryGetValue(transport, out outstanding))
     {
         Console.WriteLine("Warning: received ping to a ping that hadn't been sent!");
     }
     else
     {
         outstanding.Remove(sequence);
     }
     StatisticalMoments sm;
     if (!statistics.TryGetValue(transport, out sm))
     {
         Console.WriteLine("Weird: no statistics either");
         statistics[transport] = sm = new StatisticalMoments();
     }
     sm.Accumulate(roundtrip.TotalMilliseconds);
     Console.WriteLine("Ping #{1} {2:f}ms on {0}", transport,
         sequence, roundtrip.TotalMilliseconds);
 }
Esempio n. 3
0
 public void TestSomeData()
 {
     StatisticalMoments sm = new StatisticalMoments();
     for (int i = 0; i < 10; i++) { sm.Accumulate(i); }
     Assert.AreEqual(10, sm.Count());
     Assert.AreEqual(4.5, sm.Average());
     Assert.AreEqual(82.5, sm.UnnormalizedVariance());
     Assert.Greater(9.16667, sm.Variance());
     Assert.Less(9.16666, sm.Variance());
     Assert.AreEqual(0, sm.Skewness());
     Assert.Greater(-1.19, sm.Kurtosis());
     Assert.Less(-1.2, sm.Kurtosis());
 }
Esempio n. 4
0
 public void TestZeros()
 {
     StatisticalMoments sm = new StatisticalMoments();
     for (int i = 0; i < 5; i++) { sm.Accumulate(0); }
     Assert.AreEqual(5, sm.Count());
     Assert.AreEqual(0, sm.Average());
     Assert.AreEqual(0, sm.UnnormalizedVariance());
     Assert.AreEqual(0, sm.Variance());
     Assert.IsNaN(sm.Skewness());    // must be NaN if variance is 0
     Assert.IsNaN(sm.Kurtosis());    // must be NaN if variance is 0
 }
Esempio n. 5
0
 public void TestEmptyNaN()
 {
     StatisticalMoments sm = new StatisticalMoments();
     Assert.AreEqual(0, sm.Count());
     Assert.AreEqual(0, sm.Average());
     Assert.AreEqual(0, sm.UnnormalizedVariance());
     Assert.IsNaN(sm.Variance());
     Assert.IsNaN(sm.Skewness());
     Assert.IsNaN(sm.Kurtosis());
 }