Exemple #1
0
        public void Example1()
        {
            var stats = new WeightedMovingAverage();

            stats.Add(4);
            stats.Add(7);
            stats.Add(13);
            stats.Add(16);
            Assert.Equal(4, stats.Count);
            Assert.Equal(12.1, stats.Average, 15);
        }
Exemple #2
0
        public void Example4()
        {
            var stats = new WeightedMovingAverage();

            stats.Add(6);
            stats.Add(2);
            stats.Add(3);
            stats.Add(1);
            Assert.Equal(4, stats.Count);
            Assert.Equal(2.3, stats.Average, 15);
        }
Exemple #3
0
        public void Example3()
        {
            var stats = new WeightedMovingAverage();

            stats.Add(1000000004);
            stats.Add(1000000007);
            stats.Add(1000000013);
            stats.Add(1000000016);
            Assert.Equal(4, stats.Count);
            Assert.Equal(1000000012.1000001, stats.Average, 15);
        }
Exemple #4
0
        public void NoInfinity()
        {
            var stats = new WeightedMovingAverage();

            Assert.Throws <ArgumentOutOfRangeException>(delegate {
                stats.Add(double.NegativeInfinity);
            });
            Assert.Throws <ArgumentOutOfRangeException>(delegate {
                stats.Add(double.PositiveInfinity);
            });
            Assert.Throws <ArgumentOutOfRangeException>(delegate {
                stats.Add(double.NaN);
            });
        }
Exemple #5
0
        public void OneValue()
        {
            var stats = new WeightedMovingAverage();

            stats.Add(1);
            Assert.Equal(1, stats.Count);
            Assert.Equal(1, stats.Average);
        }