DerivateDistance extends AWeightedTrigometricDistance { @Override public double distance(final double[] a, final double[] b) { double[] derivateA = this.derivate.transform(a); double[] derivateB = this.derivate.transform(b); return this.getA() * this.timeSeriesDistance.distance(a, b) + this.getB() * this.baseDerivateDistance.distance(derivateA, derivateB); } DerivateDistance(final double alpha, final ADerivateFilter derivate, final IDistanceMetric timeSeriesDistance, final IDistanceMetric derivateDistance);  DerivateDistance(final double alpha, final IDistanceMetric timeSeriesDistance, final IDistanceMetric derivateDistance);  DerivateDistance(final double alpha, final ADerivateFilter derivate, final IDistanceMetric distance);  DerivateDistance(final double alpha, final IDistanceMetric distance); @Override double distance(final double[] a, final double[] b);  }
@Test public void testCorrectnessForDistanceCalculation() { double[] timeSeries1 = { 1, 1, 1, 1, 1, 1 }; double[] timeSeries2 = { 1, 1, 1, 1, 1, 1 }; double expectation = 0; DerivateDistance dtd = new DerivateDistance(0.5, new DynamicTimeWarping()); double distance = dtd.distance(timeSeries1, timeSeries2); assertEquals(expectation, distance, 0); }
@Test public void testCorrectnessForDistanceCalculation2() { double[] timeSeries1 = { 1, 1, 2, 2, 3, 5 }; double[] timeSeries2 = { 1, 2, 3, 5, 5, 6 }; double alpha = 0.5; IDistanceMetric timeSeriesDistance = new DynamicTimeWarping(); IDistanceMetric derivateDistance = new EuclideanDistance(); double expectation = Math.cos(alpha) * 1 + Math.sin(alpha) * Math.sqrt(7); DerivateDistance dtd = new DerivateDistance(alpha, timeSeriesDistance, derivateDistance); double distance = dtd.distance(timeSeries1, timeSeries2); assertEquals(expectation, distance, 1.0E-5); }