test_class.file: legacy/src/test/java/macrobase/analysis/stats/AutocorrelationTest.java
test_class.identifier: AutocorrelationTest
test_case.body: @Test
      public void testACF() throws Exception {
          int n = 1000;
          double[] test_input = new double[n];
          for (int i = 0; i < n; i ++) {
              if (i % 2 == 0) {
                  test_input[i] = 1;
              } else {
                  test_input[i] = -1;
              }
          }
          List<Datum> data = new ArrayList<>();
          for (int i = 0; i < n; i ++) {
              double[] value = new double[1];
              value[0] = test_input[i];
              Datum d = new Datum(new ArrayList<>(), new ArrayRealVector(value));
              data.add(d);
          }
  
          Autocorrelation acf = new Autocorrelation(10, 0);
          acf.evaluate(data);
          double[] expected_return = {0, -0.999, 0.998, -0.997, 0.996, -0.995, 0.994, -0.993, 0.992, -0.991};
          assertArrayEquals(expected_return, acf.correlations, 1e-5);
      }
test_case.class_method_signature: AutocorrelationTest.testACF()
test_case.full_signature: @Test public void testACF()
test_case.identifier: testACF
test_case.invocations: add evaluate assertArrayEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testACF()
focal_class.declarator: correlations
focal_class.modifier: public
focal_class.original_string: public double[] correlations;
focal_class.type: double[]
focal_class.var_name: correlations
focal_class.declarator: maxACF = 0
focal_class.modifier: public
focal_class.original_string: public double maxACF = 0;
focal_class.type: double
focal_class.var_name: maxACF
focal_class.declarator: fftTran = new FastFourierTransformer(DftNormalization.STANDARD)
focal_class.modifier: private
focal_class.original_string: private FastFourierTransformer fftTran = new FastFourierTransformer(DftNormalization.STANDARD);
focal_class.type: FastFourierTransformer
focal_class.var_name: fftTran
focal_class.declarator: ACF_THRESH = 0.2
focal_class.modifier: private
focal_class.original_string: private double ACF_THRESH = 0.2;
focal_class.type: double
focal_class.var_name: ACF_THRESH
focal_class.declarator: metricIdx = 1
focal_class.modifier: private
focal_class.original_string: private int metricIdx = 1;
focal_class.type: int
focal_class.var_name: metricIdx
focal_class.declarator: maxLag
focal_class.modifier: private
focal_class.original_string: private int maxLag;
focal_class.type: int
focal_class.var_name: maxLag
focal_class.file: legacy/src/main/java/macrobase/analysis/stats/Autocorrelation.java
focal_class.identifier: Autocorrelation
focal_class.class_method_signature: Autocorrelation.Autocorrelation(int maxLag, int metricIdx)
focal_class.full_signature: public  Autocorrelation(int maxLag, int metricIdx)
focal_class.identifier: Autocorrelation
focal_class.modifiers: public
focal_class.parameters: (int maxLag, int metricIdx)
focal_class.signature:  Autocorrelation(int maxLag, int metricIdx)
focal_class.class_method_signature: Autocorrelation.setMaxLag(int lag)
focal_class.full_signature: public void setMaxLag(int lag)
focal_class.identifier: setMaxLag
focal_class.modifiers: public
focal_class.parameters: (int lag)
focal_class.return: void
focal_class.signature: void setMaxLag(int lag)
focal_class.class_method_signature: Autocorrelation.setCorrelationThreshold(double thresh)
focal_class.full_signature: public void setCorrelationThreshold(double thresh)
focal_class.identifier: setCorrelationThreshold
focal_class.modifiers: public
focal_class.parameters: (double thresh)
focal_class.return: void
focal_class.signature: void setCorrelationThreshold(double thresh)
focal_class.class_method_signature: Autocorrelation.mean(double[] metrics)
focal_class.full_signature: private double mean(double[] metrics)
focal_class.identifier: mean
focal_class.modifiers: private
focal_class.parameters: (double[] metrics)
focal_class.return: double
focal_class.signature: double mean(double[] metrics)
focal_class.class_method_signature: Autocorrelation.stripDatum(List<Datum> datum)
focal_class.full_signature: private double[] stripDatum(List<Datum> datum)
focal_class.identifier: stripDatum
focal_class.modifiers: private
focal_class.parameters: (List<Datum> datum)
focal_class.return: double[]
focal_class.signature: double[] stripDatum(List<Datum> datum)
focal_class.class_method_signature: Autocorrelation.formatData(List<Datum> data)
focal_class.full_signature: private double[] formatData(List<Datum> data)
focal_class.identifier: formatData
focal_class.modifiers: private
focal_class.parameters: (List<Datum> data)
focal_class.return: double[]
focal_class.signature: double[] formatData(List<Datum> data)
focal_class.class_method_signature: Autocorrelation.evaluate(List<Datum> data)
focal_class.full_signature: public void evaluate(List<Datum> data)
focal_class.identifier: evaluate
focal_class.modifiers: public
focal_class.parameters: (List<Datum> data)
focal_class.return: void
focal_class.signature: void evaluate(List<Datum> data)
focal_class.class_method_signature: Autocorrelation.findPeaks()
focal_class.full_signature: public List<Integer> findPeaks()
focal_class.identifier: findPeaks
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: List<Integer>
focal_class.signature: List<Integer> findPeaks()
focal_method.body: public void evaluate(List<Datum> data) {
          double[] values = formatData(data);
          // FFT
          Complex[] fft = fftTran.transform(values, TransformType.FORWARD);
          // Multiply by complex conjugate
          for (int i = 0; i < fft.length; i ++) {
              fft[i] = fft[i].multiply(fft[i].conjugate());
          }
          // Inverse transform
          fft = fftTran.transform(fft, TransformType.INVERSE);
  
          correlations = new double[maxLag];
          for (int i = 1; i < maxLag; i++) {
              correlations[i] = fft[i].getReal() / fft[0].getReal();
          }
      }
focal_method.class_method_signature: Autocorrelation.evaluate(List<Datum> data)
focal_method.full_signature: public void evaluate(List<Datum> data)
focal_method.identifier: evaluate
focal_method.invocations: formatData transform multiply conjugate transform getReal getReal
focal_method.modifiers: public
focal_method.parameters: (List<Datum> data)
focal_method.return: void
focal_method.signature: void evaluate(List<Datum> data)