HilbertTransform implements IVectorTransform { @Override public double[] transform(final double[] input) { double n = input.length; double[] hilbertTransform = new double[input.length]; for (int k = 0; k < n; k++) { double sum = 0; for (int i = 0; i < n; i++) { if (i != k) { sum += input[i] / (k - i); } } hilbertTransform[k] = sum; } return hilbertTransform; }  @Override double[] transform(final double[] input);  }
@Test public void testCorrectnessForTransformation() { double[] timeSeries = { 1, 2, 3, 4, 5 }; double[] expectation = { -6.0833, -5.6666667, -4, -0.6666667, 6.41666667 }; HilbertTransform hilbertTransform = new HilbertTransform(); double[] transformed = hilbertTransform.transform(timeSeries); assertArrayEquals(expectation, transformed, 0.0001); }
@Test public void testCorrectnessForTransformation2() { double[] timeSeries = { 2, 2, 2, 2, 2 }; double[] expectation = { -4.166667, -1.666667, 0, 1.666667, 4.166667 }; HilbertTransform hilbertTransform = new HilbertTransform(); double[] transformed = hilbertTransform.transform(timeSeries); assertArrayEquals(expectation, transformed, 0.0001); }