예제 #1
0
 public void TestFriedrichCoefficients()
 {
     double[,] tss =
     {
         { 0, 1, 2, 3, 4, 5 },
         { 0, 1, 2, 3, 4, 5 }
     };
     using (KhivaArray arr = KhivaArray.Create(tss), friedrichCoeff = Features.FriedrichCoefficients(arr, 4, 2))
     {
         var result = friedrichCoeff.GetData2D <double>();
         double[,] expected =
         {
             {
                 -0.0009912563255056738, -0.0027067768387496471, -0.00015192681166809052,
                 0.10512571036815643, 0.89872437715530396
             },
             {
                 -0.0009912563255056738, -0.0027067768387496471, -0.00015192681166809052,
                 0.10512571036815643, 0.89872437715530396
             }
         };
         for (var i = 0; i < result.GetLength(0); i++)
         {
             for (var j = 0; j < result.GetLength(1); j++)
             {
                 Assert.AreEqual(expected[i, j], result[i, j], Delta);
             }
         }
     }
 }
예제 #2
0
 public void TestCountBellowMean()
 {
     float[,] tss = { { 0, 1, 2, 3, 4, 5 }, { 6, 7, 8, 9, 10, 11 } };
     using (KhivaArray arr = KhivaArray.Create(tss), countBellowMean = Features.CountBelowMean(arr))
     {
         var result = countBellowMean.GetData2D <uint>();
         Assert.AreEqual(3, result[0, 0], Delta);
         Assert.AreEqual(3, result[1, 0], Delta);
     }
 }
예제 #3
0
 public void TestGroupByDoubleKeyDoubleValueColumn()
 {
     float[,] tss = { { 0, 0, 0, 2, 2 }, { 2, 2, 2, 4, 4 }, { 0, 1, 2, 3, 4 }, { 1, 1, 1, 1, 1 } };
     using (KhivaArray arr = KhivaArray.Create(tss), groupBy = Regularization.GroupBy(arr, 0, 2, 2))
     {
         float[,] expected = { { 1, 3.5F }, { 1, 1 } };
         var result = groupBy.GetData2D <float>();
         Assert.AreEqual(expected, result);
     }
 }
예제 #4
0
 public void TestSquaredEuclidean()
 {
     int[,] tss      = { { 0, 1, 2, 3 }, { 4, 5, 6, 7 }, { 8, 9, 10, 11 } };
     int[,] expected = { { 0, 0, 0 }, { 64, 0, 0 }, { 256, 64, 0 } };
     using (KhivaArray arr = KhivaArray.Create(tss), squaredEuclidean = Distances.SquaredEuclidean(arr))
     {
         var result = squaredEuclidean.GetData2D <int>();
         Assert.AreEqual(expected, result);
     }
 }
예제 #5
0
 public void TestHamming()
 {
     int[,] tss      = { { 1, 1, 1, 1, 1 }, { 2, 2, 2, 2, 2 }, { 3, 3, 3, 3, 3 }, { 4, 4, 4, 4, 4 }, { 5, 5, 5, 5, 5 } };
     int[,] expected = { { 0, 0, 0, 0, 0 }, { 5, 0, 0, 0, 0 }, { 5, 5, 0, 0, 0 }, { 5, 5, 5, 0, 0 }, { 5, 5, 5, 5, 0 } };
     using (KhivaArray arr = KhivaArray.Create(tss), hamming = Distances.Hamming(arr))
     {
         var result = hamming.GetData2D <int>();
         Assert.AreEqual(expected, result);
     }
 }
예제 #6
0
 public void TestEuclidean()
 {
     int[,] tss        = { { 0, 1, 2, 3 }, { 4, 5, 6, 7 }, { 8, 9, 10, 11 } };
     float[,] expected = { { 0, 0, 0 }, { 8, 0, 0 }, { 16, 8, 0 } };
     using (KhivaArray arr = KhivaArray.Create(tss), euclidean = Distances.Euclidean(arr))
     {
         var result = euclidean.GetData2D <float>();
         Assert.AreEqual(expected, result);
     }
 }
예제 #7
0
 public void TestC3()
 {
     float[,] tss = { { 0, 1, 2, 3, 4, 5 }, { 6, 7, 8, 9, 10, 11 } };
     using (KhivaArray arr = KhivaArray.Create(tss), c3 = Features.C3(arr, 2))
     {
         var result = c3.GetData2D <float>();
         Assert.AreEqual(7.5, result[0, 0]);
         Assert.AreEqual(586.5, result[1, 0]);
     }
 }
예제 #8
0
 public void TestManhattan()
 {
     int[,] tss      = { { 1, 1, 1, 1, 1 }, { 2, 2, 2, 2, 2 }, { 3, 3, 3, 3, 3 }, { 4, 4, 4, 4, 4 }, { 5, 5, 5, 5, 5 } };
     int[,] expected =
     { { 0, 0, 0, 0, 0 }, { 5, 0, 0, 0, 0 }, { 10, 5, 0, 0, 0 }, { 15, 10, 5, 0, 0 }, { 20, 15, 10, 5, 0 } };
     using (KhivaArray arr = KhivaArray.Create(tss), manhattan = Distances.Manhattan(arr))
     {
         var result = manhattan.GetData2D <int>();
         Assert.AreEqual(expected, result);
     }
 }
예제 #9
0
 public void TestPercentageOfReoccurringValuesToAllValues()
 {
     float[,] tss = { { 1, 1, 2, 3, 4, 4, 5, 6 }, { 1, 2, 2, 3, 4, 5, 6, 7 } };
     using (KhivaArray arr = KhivaArray.Create(tss),
            percentage = Features.PercentageOfReoccurringValuesToAllValues(arr))
     {
         var result = percentage.GetData2D <float>();
         Assert.AreEqual(4.0 / 8.0, result[0, 0], 1e-4);
         Assert.AreEqual(2.0 / 8.0, result[1, 0], 1e-4);
     }
 }
예제 #10
0
 public void TestPercentageOfReoccurringDatapointsToAllDatapoints()
 {
     float[,] tss = { { 3, 0, 0, 4, 0, 0, 13 }, { 3, 0, 0, 4, 0, 0, 13 } };
     using (KhivaArray arr = KhivaArray.Create(tss),
            percentage = Features.PercentageOfReoccurringDatapointsToAllDatapoints(arr))
     {
         var result = percentage.GetData2D <float>();
         Assert.AreEqual(0.25, result[0, 0], 1e-4);
         Assert.AreEqual(0.25, result[1, 0], 1e-4);
     }
 }
예제 #11
0
 public void TestLls()
 {
     float[,] tss = { { 4, 3 }, { -1, -2 } };
     float[] tss2 = { 3, 1 };
     using (KhivaArray a = KhivaArray.Create(tss), b = KhivaArray.Create(tss2), lls = LinAlg.Lls(a, b))
     {
         var result = lls.GetData2D <float>();
         Assert.AreEqual(1, result[0, 0], Delta);
         Assert.AreEqual(1, result[0, 1], Delta);
     }
 }
예제 #12
0
 public void TestCwtCoefficients()
 {
     double[,] tss = { { 0.1, 0.2, 0.3 }, { 0.1, 0.2, 0.3 } };
     int[] width = { 1, 2, 3 };
     using (KhivaArray arr = KhivaArray.Create(tss),
            widthArr = KhivaArray.Create(width),
            cwtCoeff = Features.CwtCoefficients(arr, widthArr, 2, 2))
     {
         var result = cwtCoeff.GetData2D <float>();
         Assert.AreEqual(0.26517161726951599, result[0, 0], Delta);
         Assert.AreEqual(0.26517161726951599, result[1, 0], Delta);
     }
 }
예제 #13
0
 public void TestStdev()
 {
     double[,] tss = { { 0, 1, 2, 3, 4, 5 }, { 2, 2, 2, 20, 30, 25 } };
     using (KhivaArray arr = KhivaArray.Create(tss), stdev = Statistics.SampleStdevStatistics(arr))
     {
         double[] expected = { 1.870828693, 12.988456413 };
         var      result   = stdev.GetData2D <double>();
         for (var i = 0; i < result.GetLength(0); i++)
         {
             Assert.AreEqual(expected[i], result[i, 0], 1e-2);
         }
     }
 }
예제 #14
0
 public void TestKurtosis()
 {
     double[,] tss = { { 0, 1, 2, 3, 4, 5 }, { 2, 2, 2, 20, 30, 25 } };
     using (KhivaArray arr = KhivaArray.Create(tss), kurtosis = Statistics.KurtosisStatistics(arr))
     {
         double[] expected = { -1.2, -2.66226722 };
         var      result   = kurtosis.GetData2D <double>();
         for (var i = 0; i < result.GetLength(0); i++)
         {
             Assert.AreEqual(expected[i], result[i, 0], 1e-2);
         }
     }
 }
예제 #15
0
 public void TestSkewness()
 {
     double[,] tss = { { 0, 1, 2, 3, 4, 5 }, { 2, 2, 2, 20, 30, 25 } };
     using (KhivaArray arr = KhivaArray.Create(tss), skewness = Statistics.SkewnessStatistics(arr))
     {
         double[] expected = { 0.0, 0.236177069879499 };
         var      result   = skewness.GetData2D <double>();
         for (var i = 0; i < result.GetLength(0); i++)
         {
             Assert.AreEqual(expected[i], result[i, 0], 1e-2);
         }
     }
 }
예제 #16
0
 public void TestLjungBox()
 {
     double[,] tss = { { 0, 1, 2, 3 }, { 4, 5, 6, 7 } };
     using (KhivaArray arr = KhivaArray.Create(tss), ljungBox = Statistics.LjungBox(arr, 3))
     {
         double[] expected = { 6.4400, 6.4400 };
         var      result   = ljungBox.GetData2D <double>();
         for (var i = 0; i < result.GetLength(0); i++)
         {
             Assert.AreEqual(expected[i], result[i, 0], Delta);
         }
     }
 }
예제 #17
0
 public void TestLocalMaximals()
 {
     float[,] tss =
     { { 0.0F, 4.0F, 3.0F, 5.0F, 4.0F, 1.0F, 0.0F, 4.0F }, { 0.0F, 4.0F, 3.0F, 5.0F, 4.0F, 1.0F, 0.0F, 4.0F } };
     using (KhivaArray arr = KhivaArray.Create(tss), localMaximals = Features.LocalMaximals(arr))
     {
         var result = localMaximals.GetData2D <float>();
         float[,] expected =
         {
             { 0.0F, 1.0F, 0.0F, 1.0F, 0.0F, 0.0F, 0.0F, 1.0F }, { 0.0F, 1.0F, 0.0F, 1.0F, 0.0F, 0.0F, 0.0F, 1.0F }
         };
         Assert.AreEqual(expected, result);
     }
 }
예제 #18
0
 public void TestRangeCount()
 {
     int[,] tss =
     {
         { 3, 0, 0, 4, 0, 0, 13 },
         { 3, 0, 5, 4, 0, 0, 13 }
     };
     using (KhivaArray arr = KhivaArray.Create(tss), rangeCount = Features.RangeCount(arr, 2, 12))
     {
         var result = rangeCount.GetData2D <int>();
         Assert.AreEqual(2, result[0, 0]);
         Assert.AreEqual(3, result[1, 0]);
     }
 }
예제 #19
0
 public void TestNumberPeaks()
 {
     float[,] tss =
     {
         { 3, 0, 0, 4, 0, 0, 13 },
         { 3, 0, 0, 4, 0, 0, 13 }
     };
     using (KhivaArray arr = KhivaArray.Create(tss), numberPeaks = Features.NumberPeaks(arr, 2))
     {
         var result = numberPeaks.GetData2D <float>();
         Assert.AreEqual(1, result[0, 0], 1e-4);
         Assert.AreEqual(1, result[1, 0], 1e-4);
     }
 }
예제 #20
0
 public void TestNumberCwtPeaks()
 {
     double[,] tss =
     {
         { 1, 1, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 1, 1 },
         { 1, 1, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 1, 1 }
     };
     using (KhivaArray arr = KhivaArray.Create(tss), numberCwtPeaks = Features.NumberCwtPeaks(arr, 2))
     {
         var result = numberCwtPeaks.GetData2D <double>();
         Assert.AreEqual(2, result[0, 0]);
         Assert.AreEqual(2, result[1, 0]);
     }
 }
예제 #21
0
 public void TestNumberCrossingM()
 {
     long[,] tss =
     {
         { 1, 2, 1, 1, -3, -4, 7, 8, 9, 10, -2, 1, -3, 5, 6, 7, -10 },
         { 1, 2, 1, 1, -3, -4, 7, 8, 9, 10, -2, 1, -3, 5, 6, 7, -10 }
     };
     using (KhivaArray arr = KhivaArray.Create(tss), numberCrossingM = Features.NumberCrossingM(arr, 0))
     {
         var result = numberCrossingM.GetData2D <long>();
         Assert.AreEqual(7, result[0, 0], Delta);
         Assert.AreEqual(7, result[1, 0], Delta);
     }
 }
예제 #22
0
 public void TestMinimum()
 {
     int[,] tss =
     {
         { 20, 20, 20, 18, 25, 19, 20, 20, 20, 20, 40, 30,  1, 50, 13, 15, 5, 16, 20, 20 },
         { 20, 20, 20,  2, 19,  4, 20, 20, 20,  4, 15,  6, 30,  7,  9, 18, 4, 10, 20, 20 }
     };
     using (KhivaArray arr = KhivaArray.Create(tss), minimum = Features.Minimum(arr))
     {
         var result = minimum.GetData2D <int>();
         Assert.AreEqual(1, result[0, 0], Delta);
         Assert.AreEqual(2, result[1, 0], Delta);
     }
 }
예제 #23
0
 public void TestMedian()
 {
     float[,] tss =
     {
         { 20, 20, 20, 18, 25, 19, 20, 20, 20, 20, 40, 30,  1, 50, 1,  1, 5, 1, 20, 20 },
         { 20, 20, 20,  2, 19,  1, 20, 20, 20,  1, 15,  1, 30,  1, 1, 18, 4, 1, 20, 20 }
     };
     using (KhivaArray arr = KhivaArray.Create(tss), median = Features.Median(arr))
     {
         var result = median.GetData2D <float>();
         Assert.AreEqual(20, result[0, 0], Delta);
         Assert.AreEqual(18.5, result[1, 0], Delta);
     }
 }
예제 #24
0
 public void TestMaximum()
 {
     long[,] tss =
     {
         { 20, 20, 20, 18, 25, 19, 20, 20, 20, 20, 40, 30,  1, 50, 1,  1, 5, 1, 20, 20 },
         { 20, 20, 20,  2, 19,  1, 20, 20, 20,  1, 15,  1, 30,  1, 1, 18, 4, 1, 20, 20 }
     };
     using (KhivaArray arr = KhivaArray.Create(tss), maximum = Features.Maximum(arr))
     {
         var result = maximum.GetData2D <long>();
         Assert.AreEqual(50, result[0, 0]);
         Assert.AreEqual(30, result[1, 0]);
     }
 }
예제 #25
0
 public void TestLength()
 {
     long[,] tss =
     {
         { 0, 4, 3, 5, 5, 1 },
         { 0, 4, 3, 2, 5, 1 }
     };
     using (KhivaArray arr = KhivaArray.Create(tss), length = Features.Length(arr))
     {
         var result = length.GetData2D <int>();
         Assert.AreEqual(6, result[0, 0]);
         Assert.AreEqual(6, result[0, 1]);
     }
 }
예제 #26
0
 public void TestRatioValueNumberToTimeSeriesLength()
 {
     double[,] tss =
     {
         { 3, 0, 0, 4, 0, 0, 13 },
         { 3, 5, 0, 4, 6, 0, 13 }
     };
     using (KhivaArray arr = KhivaArray.Create(tss), ratio = Features.RatioValueNumberToTimeSeriesLength(arr))
     {
         var result = ratio.GetData2D <double>();
         Assert.AreEqual(4.0 / 7.0, result[0, 0], 1e-4);
         Assert.AreEqual(6.0 / 7.0, result[1, 0], 1e-4);
     }
 }
예제 #27
0
 public void TestRatioBeyondRSigma()
 {
     double[,] tss =
     {
         { 3, 0, 0, 4, 0, 0, 13 },
         { 3, 0, 0, 4, 0, 0, 13 }
     };
     using (KhivaArray arr = KhivaArray.Create(tss), ratioBeyondRSigma = Features.RatioBeyondRSigma(arr, 0.5F))
     {
         var result = ratioBeyondRSigma.GetData2D <double>();
         Assert.AreEqual(0.7142857142857143, result[0, 0], 1e-4);
         Assert.AreEqual(0.7142857142857143, result[1, 0], 1e-4);
     }
 }
예제 #28
0
        public void TestAggregatedAutocorrelation()
        {
            var tss = new float[, ] {
                { 1, 2, 3, 4, 5, 6 }, { 7, 8, 9, 10, 11, 12 }
            };

            using (KhivaArray arr = KhivaArray.Create(tss),
                   aggregatedAutocorrelation = Features.AggregatedAutoCorrelation(arr, 0))
            {
                var result = aggregatedAutocorrelation.GetData2D <float>();
                Assert.AreEqual(-0.6571428571428571F, result[0, 0], Delta);
                Assert.AreEqual(-0.6571428571428571F, result[1, 0], Delta);
            }
        }
예제 #29
0
 public void TestSampleEntropy()
 {
     float[,] tss =
     {
         { 3, 0, 0, 4, 0, 0, 13 },
         { 3, 0, 0, 4, 0, 0, 13 }
     };
     using (KhivaArray arr = KhivaArray.Create(tss), sampleEntropy = Features.SampleEntropy(arr))
     {
         var result = sampleEntropy.GetData2D <float>();
         Assert.AreEqual(1.2527629, result[0, 0], 1e-4);
         Assert.AreEqual(1.2527629, result[0, 1], 1e-4);
     }
 }
예제 #30
0
 public void TestLastLocationOfMinimum()
 {
     double[,] tss =
     {
         { 0, 4, 3, 5, 5, 1, 0, 4 },
         { 3, 2, 5, 1, 4, 5, 1, 2 }
     };
     using (KhivaArray arr = KhivaArray.Create(tss), lastLocationOfMinimum = Features.LastLocationOfMinimum(arr))
     {
         var result = lastLocationOfMinimum.GetData2D <double>();
         Assert.AreEqual(0.875, result[0, 0], Delta);
         Assert.AreEqual(0.875, result[1, 0], Delta);
     }
 }