StretchingComplexity implements ITimeSeriesComplexity { @Override public double complexity(final double[] t) { int n = t.length; double sum = .0; for (int i = 0; i < n - 1; i++) { sum += Math.sqrt(1 + Math.pow(t[i + 1] - t[i], 2)); } return sum; }  @Override double complexity(final double[] t);  }
@Test public void testComplexityCalculation() throws IllegalArgumentException { StretchingComplexity sc = new StretchingComplexity(); double complexity = sc.complexity(timeSeries1); double expectation = 5; String message = "Calculated %f, but %f was expected"; assertEquals(String.format(message, complexity, expectation), expectation, complexity, 0.001); }
@Test public void testComplexityCalculation2() throws IllegalArgumentException { StretchingComplexity sc = new StretchingComplexity(); double complexity = sc.complexity(timeSeries2); double expectation = 15; String message = "Calculated %f, but %f was expected"; assertEquals(String.format(message, complexity, expectation), expectation, complexity, 0.001); }