DerivateTransformDistance implements IDistanceMetric { @Override public double distance(final double[] a, final double[] b) { double[] derivateA = this.derivate.transform(a); double[] derivateB = this.derivate.transform(b); double[] transformA = this.transform.transform(a); double[] transformB = this.transform.transform(b); return this.a * this.timeSeriesDistance.distance(a, b) + this.b * this.derivateDistance.distance(derivateA, derivateB) + this.c * this.transformDistance.distance(transformA, transformB); } DerivateTransformDistance(final double a, final double b, final double c, final ADerivateFilter derivate, final IVectorTransform transform, final IDistanceMetric timeSeriesDistance, final IDistanceMetric derivateDistance,
			final IDistanceMetric transformDistance);  DerivateTransformDistance(final double a, final double b, final double c, final IDistanceMetric timeSeriesDistance, final IDistanceMetric derivateDistance, final IDistanceMetric transformDistance);  DerivateTransformDistance(final double a, final double b, final double c, final ADerivateFilter derivate, final IVectorTransform transform, final IDistanceMetric distance);  DerivateTransformDistance(final double a, final double b, final double c, final IDistanceMetric distance); @Override double distance(final double[] a, final double[] b); void setA(final double a); void setB(final double b); void setC(final double c); double getA(); double getB(); double getC();  }
@Test public void testCorrectnessForDistanceCalculation() { double[] timeSeries1 = { 1, 1, 1, 1, 1, 1 }; double[] timeSeries2 = { 1, 1, 1, 1, 1, 1 }; double expectation = 0; TransformDistance dtd = new TransformDistance(0.5, new DynamicTimeWarping()); double distance = dtd.distance(timeSeries1, timeSeries2); assertEquals(expectation, distance, 0); }
@Test public void testCorrectnessForDistanceCalculation2() { double[] timeSeries1 = { 1, 2, 3, 4, 5 }; double[] timeSeries2 = { 2, 2, 2, 2, 2 }; double a = 0.5; double b = 0.25; double c = 0.25; ADerivateFilter derivate = new BackwardDifferenceDerivate(); IVectorTransform transform = new HilbertTransform(); IDistanceMetric euclideanDistance = new EuclideanDistance(); double expectation = a * Math.sqrt(15) + b * Math.sqrt(4) + c * 6.79562; DerivateTransformDistance dtd = new DerivateTransformDistance(a, b, c, derivate, transform, euclideanDistance); double distance = dtd.distance(timeSeries1, timeSeries2); assertEquals(expectation, distance, 1.0E-5); }