Class DynamicTimeWarping

  • All Implemented Interfaces:
    org.api4.java.common.math.IMetric<double[]>, IDistanceMetric

    public class DynamicTimeWarping
    extends java.lang.Object
    implements IDistanceMetric
    Implementation of the Dynamic Time Warping (DTW) measure as published in "Using Dynamic Time Warping to FindPatterns in Time Series" Donald J. Berndt and James Clifford. In DTW the time series are "warped" non-linearly in the time dimension to determine a measure of their similarity independent of certain non-linear variations in the time dimension. Given two time series A and B the dynamic programming formulation is based on the following recurrent definition: gamma(i,j) = delta(i,j) + min {gamma(i-1, j), gamma(i-1,j-1), gamma(i, j-1)} where gamma(i,j) is the cummulative distance up to i,j and delta(i,j) is the point distance between A_i and B_i.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double distance​(double[] a, double[] b)
      Calculates the distance between two time series.
      double distanceWithWindow​(double[] a, double[] b, int w)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DynamicTimeWarping

        public DynamicTimeWarping()
        Creates an instance with absolute distance as point distance.
      • DynamicTimeWarping

        public DynamicTimeWarping​(IScalarDistance delta)
        Creates an instance with a given scalar distance measure.
        Parameters:
        delta - Scalar distance measure.
    • Method Detail

      • distance

        public double distance​(double[] a,
                               double[] b)
        Description copied from interface: IDistanceMetric
        Calculates the distance between two time series.
        Specified by:
        distance in interface IDistanceMetric
        Parameters:
        a - First time series.
        b - Second time series.
        Returns:
        Distance between the first and second time series.
      • distanceWithWindow

        public double distanceWithWindow​(double[] a,
                                         double[] b,
                                         int w)