Beispiel #1
0
        public void ARIM_Diff_Recursive_Test()
        {
            var dict = new Dictionary <string, List <object> >
            {
                { "a", new List <object>()
                  {
                      1, 2, 3, 4, 5, 6
                  } },
                { "b", new List <object>()
                  {
                      1, 1, 2, 3, 5, 8
                  } },
                { "c", new List <object>()
                  {
                      1, 4, 9, 16, 25, 36
                  } },
            };
            //
            var df = new DataFrame(dict);

            //seasonal differencing period 1
            var newDf = df.Diff(1, type: DiffType.Recurrsive);

            Assert.Equal(new List <object>()
            {
                DataFrame.NAN, 1, 1, 1, 1, 1
            }, newDf["a"]);
            Assert.Equal(new List <object>()
            {
                DataFrame.NAN, 0, 1, 1, 2, 3
            }, newDf["b"]);
            Assert.Equal(new List <object>()
            {
                DataFrame.NAN, 3, 5, 7, 9, 11
            }, newDf["c"]);

            //seasonal differencing period 2
            newDf = df.Diff(step: 2, type: DiffType.Recurrsive);
            Assert.Equal(new List <object>()
            {
                DataFrame.NAN, DataFrame.NAN, 0, 0, 0, 0
            }, newDf["a"]);
            Assert.Equal(new List <object>()
            {
                DataFrame.NAN, DataFrame.NAN, 1, 0, 1, 1
            }, newDf["b"]);
            Assert.Equal(new List <object>()
            {
                DataFrame.NAN, DataFrame.NAN, 2, 2, 2, 2
            }, newDf["c"]);

            //seasonal differencing period 3
            newDf = df.Diff(step: 3, type: DiffType.Recurrsive);
            Assert.Equal(new List <object>()
            {
                DataFrame.NAN, DataFrame.NAN, DataFrame.NAN, 0, 0, 0
            }, newDf["a"]);
            Assert.Equal(new List <object>()
            {
                DataFrame.NAN, DataFrame.NAN, DataFrame.NAN, -1, 1, 0
            }, newDf["b"]);
            Assert.Equal(new List <object>()
            {
                DataFrame.NAN, DataFrame.NAN, DataFrame.NAN, 0, 0, 0
            }, newDf["c"]);
        }
Beispiel #2
0
        public void ARIM_Differencing_Test()
        {
            var dict = new Dictionary <string, List <object> >
            {
                { "a", new List <object>()
                  {
                      1, 2, 3, 4, 5, 6
                  } },
                { "b", new List <object>()
                  {
                      1, 1, 2, 3, 5, 8
                  } },
                { "c", new List <object>()
                  {
                      1, 4, 9, 16, 25, 36
                  } },
            };
            //
            var df = new DataFrame(dict);

            //seasonal differencing period 1
            var newDf = df.Diff(step: 1);

            Assert.Equal(new List <object>()
            {
                DataFrame.NAN, 1, 1, 1, 1, 1
            }, newDf["a"]);
            Assert.Equal(new List <object>()
            {
                DataFrame.NAN, 0, 1, 1, 2, 3
            }, newDf["b"]);
            Assert.Equal(new List <object>()
            {
                DataFrame.NAN, 3, 5, 7, 9, 11
            }, newDf["c"]);

            //seasonal differencing period 2
            newDf = df.Diff(step: 2);
            Assert.Equal(new List <object>()
            {
                DataFrame.NAN, DataFrame.NAN, 2, 2, 2, 2
            }, newDf["a"]);
            Assert.Equal(new List <object>()
            {
                DataFrame.NAN, DataFrame.NAN, 1, 2, 3, 5
            }, newDf["b"]);
            Assert.Equal(new List <object>()
            {
                DataFrame.NAN, DataFrame.NAN, 8, 12, 16, 20
            }, newDf["c"]);

            //seasonal differencing period 3
            newDf = df.Diff(step: 3);
            Assert.Equal(new List <object>()
            {
                DataFrame.NAN, DataFrame.NAN, DataFrame.NAN, 3, 3, 3
            }, newDf["a"]);
            Assert.Equal(new List <object>()
            {
                DataFrame.NAN, DataFrame.NAN, DataFrame.NAN, 2, 4, 6
            }, newDf["b"]);
            Assert.Equal(new List <object>()
            {
                DataFrame.NAN, DataFrame.NAN, DataFrame.NAN, 15, 21, 27
            }, newDf["c"]);
        }