Class DTWDistance

  • All Implemented Interfaces:
    Distance<NumberVector>, NumberVectorDistance<NumberVector>, PrimitiveDistance<NumberVector>
    Direct Known Subclasses:
    DerivativeDTWDistance, EDRDistance, ERPDistance

    @Title("Dynamic Time Warping Distance Function")
    @Reference(authors="D. Berndt, J. Clifford",
               title="Using dynamic time warping to find patterns in time series",
               booktitle="AAAI-94 Workshop on Knowledge Discovery in Databases, 1994",
               url="http://www.aaai.org/Papers/Workshops/1994/WS-94-03/WS94-03-031.pdf",
               bibkey="DBLP:conf/kdd/BerndtC94")
    public class DTWDistance
    extends AbstractEditDistance
    Dynamic Time Warping distance (DTW) for numerical vectors.

    Reference:

    D. Berndt and J. Clifford
    Using dynamic time warping to find patterns in time series
    AAAI-94 Workshop on Knowledge Discovery in Databases, 1994

    This implementation uses a buffer storing two rows.

    TODO: allow different one-dimensional distances

    Since:
    0.2
    Author:
    Thomas Bernecker, Erich Schubert
    • Constructor Detail

      • DTWDistance

        public DTWDistance()
        Constructor.
      • DTWDistance

        public DTWDistance​(double bandSize)
        Constructor.
        Parameters:
        bandSize - Band size
    • Method Detail

      • distance

        public double distance​(NumberVector v1,
                               NumberVector v2)
        Description copied from interface: NumberVectorDistance
        Computes the distance between two given vectors according to this distance function.
        Parameters:
        v1 - first vector
        v2 - second vector
        Returns:
        the distance between two given vectors according to this distance function
      • firstRow

        protected void firstRow​(double[] buf,
                                int band,
                                NumberVector v1,
                                NumberVector v2,
                                int dim2)
        Fill the first row.
        Parameters:
        buf - Buffer
        band - Bandwidth
        v1 - First vector
        v2 - Second vector
        dim2 - Dimensionality of second
      • delta

        protected double delta​(double val1,
                               double val2)
        Compute the delta of two values.

        TODO: support Euclidean, Manhattan, others?

        Parameters:
        val1 - First value
        val2 - Second value
        Returns:
        Difference