# WarpingDistance

WarpingDistance[s1,s2]

gives the dynamic time warping (DTW) distance between sequences s1 and s2.

WarpingDistance[s1,s2,win]

uses a window specified by win for local search.

# Details and Options

• WarpingDistance gives the minimal distance for any correspondence between the reference sequence s1 and the query sequence s2.
• The distance is given by , where s1ni and s2mi are corresponding elements.
• Compute the effective correspondence using WarpingCorrespondence.
• The sequences si can be lists of numeric or Boolean scalars or vectors.
• Possible settings for the search window win are:
•  Automatic a full search r a slanted band window of radius {"SlantedBand",r} a slanted band window of radius {"Band",r} band window of radius (Sakoe-Chiba) {"Parallelogram",a} parallelogram window placed at origin with slopes and (Itakura)
• A smaller typically gives a faster but less optimal result. If , then has no effect.
• The following options are supported:
•  DistanceFunction Automatic the distance function to be used Method Automatic the variant of DTW to use
• WarpingDistance accepts a option with settings:
•  Automatic automatically determine distance function EuclideanDistance Euclidean distance ManhattanDistance Manhattan or "city block" distance BinaryDistance 0 if elements are equal; 1 otherwise ChessboardDistance Chebyshev or sup norm distance SquaredEuclideanDistance squared Euclidean distance NormalizedSquaredEuclideanDistance normalized squared Euclidean distance CosineDistance angular cosine distance CorrelationDistance correlation coefficient distance BrayCurtisDistance Total[Abs[u-v]]/Total[Abs[u+v]] CanberraDistance Total[Abs[u-v]/(Abs[u]+Abs[v])] MatchingDissimilarity matching dissimilarity between Boolean vectors
• By default, the following distance functions are used:
•  EuclideanDistance numeric data MatchingDissimilarity Boolean data
• Using , all elements of s2 are matched with all elements of s1.
• Using Method->{"MatchingInterval"match}, s2 can be matched with a subsequence of s1. Possible settings for match include:
•  Automatic a full match "Flexible" flexible at both ends "FlexibleEnd" flexible only at the end of the interval

# Examples

open allclose all

## Basic Examples(1)

Find the time warping distance between two sequences of values:

 In[1]:=
 Out[1]=

Show the correspondence between the sequences:

 In[2]:=
 Out[2]=