Push() public method

Registers the occurrence of a value.
public Push ( double value ) : void
value double The value to be registered.
return void
        public void ClearTest()
        {
            double[] values = { 0.5, -1.2, 0.7, 0.2, 1.1 };

            RunningNormalStatistics target = new RunningNormalStatistics();

            for (int i = 0; i < values.Length; i++)
                target.Push(values[i]);

            target.Clear();

            double[] values2 = { 1.5, -5.2, 0.7, 1.2, 9.1 };

            for (int i = 0; i < values.Length; i++)
                target.Push(values2[i]);

            Assert.AreEqual(values2.Mean(), target.Mean, 1e-10);
            Assert.AreEqual(values2.StandardDeviation(), target.StandardDeviation, 1e-10);
            Assert.AreEqual(values2.Variance(), target.Variance, 1e-10);
        }
        public void StandardDeviationTest()
        {
            double[] values = { 0.5, -1.2, 0.7, 0.2, 1.1 };

            RunningNormalStatistics target = new RunningNormalStatistics();

            for (int i = 0; i < values.Length; i++)
                target.Push(values[i]);

            double expected = values.StandardDeviation();
            double actual = target.StandardDeviation;

            Assert.AreEqual(expected, actual);
        }
        public void VarianceTest()
        {
            double[] values = { 0.5, -1.2, 0.7, 0.2, 1.1 };

            RunningNormalStatistics target = new RunningNormalStatistics();

            for (int i = 0; i < values.Length; i++)
                target.Push(values[i]);

            double expected = Tools.Variance(values);
            double actual = target.Variance;

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 4
0
 public double TestUtility()
 {
     RunningNormalStatistics utilityAve = new RunningNormalStatistics();
     int counter = 0;
     foreach (var a in stats) {
         if (a.Value.ElementsSeen > 20) {
             utilityAve.Push(a.Value.ProbabilisticUtility());
             counter++;
         }
     }
     if (counter > 8) {
         return utilityAve.Mean;
     } else {
         //Debug.Print(counter.ToString());
         return -1;
     }
 }