TransformDistance extends AWeightedTrigometricDistance { @Override public double distance(final double[] a, final double[] b) { double[] transformA = this.transform.transform(a); double[] transformB = this.transform.transform(b); return this.getA() * this.timeSeriesDistance.distance(a, b) + this.getB() * this.baseTransformDistance.distance(transformA, transformB); } TransformDistance(final double alpha, final IVectorTransform transform, final IDistanceMetric timeSeriesDistance, final IDistanceMetric transformDistance);  TransformDistance(final double alpha, final IDistanceMetric timeSeriesDistance, final IDistanceMetric transformDistance);  TransformDistance(final double alpha, final IVectorTransform transform, final IDistanceMetric distance);  TransformDistance(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; TransformDistance td = new TransformDistance(0.5, new DynamicTimeWarping()); double distance = td.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 alpha = 0.5; IVectorTransform transform = new HilbertTransform(); IDistanceMetric euclideanDistance = new EuclideanDistance(); double expectation = Math.cos(alpha) * Math.sqrt(15) + Math.sin(alpha) * 6.79562; TransformDistance td = new TransformDistance(alpha, transform, euclideanDistance); double distance = td.distance(timeSeries1, timeSeries2); assertEquals(expectation, distance, 1.0E-5); }