Ejemplo n.º 1
0
        public void PushTest2()
        {
            double[] values = { 0.24, 1.61, 2.22, 5.82 };

            int windowSize = values.Length;

            var target = new MovingCircularStatistics(windowSize);

            target.Push(0.29);
            target.Push(1.11);

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

            double actualMean   = target.Mean;
            double expectedMean = Circular.Mean(values);

            Assert.AreEqual(expectedMean, actualMean, 1e-10);

            double actualVariance   = target.Variance;
            double expectedVariance = Circular.Variance(values);

            Assert.AreEqual(expectedVariance, actualVariance, 1e-10);
        }
Ejemplo n.º 2
0
        public void circular_test()
        {
            double[] values = Vector.Range(2.0, 5.0, 0.1);

            int windowSize = values.Length;

            Assert.AreEqual(30, windowSize);

            var target = new MovingCircularStatistics(windowSize);

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

            double actualMean   = target.Mean;
            double expectedMean = Circular.Mean(values);
            double wrongMean    = values.Mean();

            Assert.AreEqual(actualMean, -2.8331853071795865, 1e-10);
            Assert.AreEqual(wrongMean, 3.45, 1e-10);
            Assert.AreEqual(expectedMean, actualMean, 1e-10);

            double actualVariance   = target.Variance;
            double expectedVariance = Circular.Variance(values);
            double wrongVar         = values.Variance();

            Assert.AreEqual(actualVariance, 0.33472617948636552);
            Assert.AreEqual(wrongVar, 0.77500000000000013);
            Assert.AreEqual(expectedVariance, actualVariance);

            double actualStdDev   = target.StandardDeviation;
            double expectedStdDev = Circular.StandardDeviation(values);
            double wrongStdDev    = values.StandardDeviation();

            Assert.AreEqual(actualStdDev, 0.90283615668111072);
            Assert.AreEqual(wrongStdDev, 0.88034084308295057);
            Assert.AreEqual(expectedStdDev, actualStdDev);
        }
Ejemplo n.º 3
0
        public void constant_value_test()
        {
            double[] values = { 0.24, 0.24, 0.24, 0.24 };

            int windowSize = values.Length;

            var target = new MovingCircularStatistics(windowSize);

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

            double actualMean   = target.Mean;
            double expectedMean = Circular.Mean(values);

            Assert.AreEqual(expectedMean, actualMean, 1e-10);

            double actualVariance   = target.Variance;
            double expectedVariance = Circular.Variance(values);

            Assert.AreEqual(expectedVariance, actualVariance, 1e-10);
        }
        public void circular_test()
        {
            double[] values = Vector.Range(2.0, 5.0, 0.1);

            int windowSize = values.Length;

            var target = new MovingCircularStatistics(windowSize);

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

            double actualMean   = target.Mean;
            double expectedMean = Circular.Mean(values);
            double wrongMean    = values.Mean();

            Assert.AreEqual(actualMean, -2.8328292495480087, 1e-10);
            Assert.AreEqual(wrongMean, 3.4533333333333331, 1e-10);
            Assert.AreEqual(expectedMean, actualMean, 1e-10);

            double actualVariance   = target.Variance;
            double expectedVariance = Circular.Variance(values);
            double wrongVar         = values.Variance();

            Assert.AreEqual(actualVariance, 0.33804973557846185);
            Assert.AreEqual(wrongVar, 0.78533333333333344);
            Assert.AreEqual(expectedVariance, actualVariance);

            double actualStdDev   = target.StandardDeviation;
            double expectedStdDev = Circular.StandardDeviation(values);
            double wrongStdDev    = values.StandardDeviation();

            Assert.AreEqual(actualStdDev, 0.90836650658209);
            Assert.AreEqual(wrongStdDev, 0.88619034825105913);
            Assert.AreEqual(expectedStdDev, actualStdDev);
        }