Пример #1
0
        public void Example9()
        {
            var stats = new WeightedMovingAverage();

            stats.AddRange(new double[] { -5, -3, -1, 1, 3 });
            Assert.Equal(5, stats.Count);
            Assert.Equal(0.333333333333333, stats.Average, 15);
        }
Пример #2
0
        public void Example8()
        {
            var stats = new WeightedMovingAverage();

            stats.AddRange(new double[] { 51.3, 55.6, 49.9, 52.0 });
            Assert.Equal(4, stats.Count);
            Assert.Equal(52.02, stats.Average, 15);
        }
Пример #3
0
        public void Example7()
        {
            var stats = new WeightedMovingAverage();

            stats.AddRange(new double[] { 9, 2, 5, 4, 12, 7, 8, 11, 9, 3, 7, 4, 12, 5, 4, 10, 9, 6, 9, 4 });
            Assert.Equal(20, stats.Count);
            Assert.Equal(6.963636363636364, stats.Average, 15);
        }
Пример #4
0
        public void Example6()
        {
            var stats = new WeightedMovingAverage();

            stats.AddRange(new double[] { 2, 4, 4, 4, 5, 5, 7, 9 });
            Assert.Equal(8, stats.Count);
            Assert.Equal(5.944444444444445, stats.Average, 15);
        }
Пример #5
0
        public void Example20()
        {
            var stats = new WeightedMovingAverage(3);

            stats.AddRange(new double[] { -1, 0, 1 });
            Assert.Equal(3, stats.Count);
            Assert.Equal(0.333333333333333, stats.Average, 15);
        }
Пример #6
0
 public void NoNullCollection()
 {
     Assert.Throws <ArgumentNullException>(delegate {
         var stats = new WeightedMovingAverage(null);
     });
     Assert.Throws <ArgumentNullException>(delegate {
         var stats = new WeightedMovingAverage(10, null);
     });
     Assert.Throws <ArgumentNullException>(delegate {
         var stats = new WeightedMovingAverage();
         stats.AddRange(null);
     });
 }