WarpingCorrespondence
✖
WarpingCorrespondence
gives the time warping (DTW) similarity path between sequences s1 and s2.
Details and Options



- WarpingCorrespondence is also known as dynamic time warping.
- WarpingCorrespondence returns {{n1,…,nk},{m1,…,mk}} of nondecreasing positions such that s1〚ni〛 correspond to s2〚mi〛.
- The returned positions attempt to minimize the distance
over all possible such positions, and with the constraint that all elements of s1 and s2 are represented as some s1〚ni〛 and s2〚mj〛, respectively.
- Compute the effective distance using WarpingDistance.
- 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 - WarpingCorrespondence accepts a DistanceFunctiond 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 Method->Automatic, 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 allBasic Examples (1)Summary of the most common use cases
Find the time warping correspondence between two sequences:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-ikif28

https://wolfram.com/xid/0hyzokcy3pp7qs2i-cnyv01

Plot the correspondence between indices:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-t8vgxj

Find the time warped versions:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-8ql6ui


https://wolfram.com/xid/0hyzokcy3pp7qs2i-y2pty6

The warped versions are approximately equal:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-6j6ja9

Scope (9)Survey of the scope of standard use cases
Data (6)
Find the time warping correspondence between two real-valued vectors:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-k639lv

Find the time warping correspondence between two sequences of vectors:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-vftgtj

https://wolfram.com/xid/0hyzokcy3pp7qs2i-ugclhw

Find the time warping correspondence between two Boolean vectors:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-uxok45


https://wolfram.com/xid/0hyzokcy3pp7qs2i-vw8iqp


https://wolfram.com/xid/0hyzokcy3pp7qs2i-by8gpk

Sequences of Boolean-valued vectors:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-rfnt09

https://wolfram.com/xid/0hyzokcy3pp7qs2i-ck4695

Sequences of quantities with compatible units:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-mqt072

https://wolfram.com/xid/0hyzokcy3pp7qs2i-g4ussc

Two-dimensional quantity arrays:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-9hl3wz


https://wolfram.com/xid/0hyzokcy3pp7qs2i-3zzrt4


https://wolfram.com/xid/0hyzokcy3pp7qs2i-lyzqtd

Search Window (3)
By default, the search is not locally constrained:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-sg6rii

https://wolfram.com/xid/0hyzokcy3pp7qs2i-tysjf3


https://wolfram.com/xid/0hyzokcy3pp7qs2i-et0584

Specify a radius for the search window:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-pre4gv

A search radius of 2 allows you to find the optimal alignment:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-ygolea


https://wolfram.com/xid/0hyzokcy3pp7qs2i-i4tkpv

https://wolfram.com/xid/0hyzokcy3pp7qs2i-c3cgs

Use a parallelogram of slope 3:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-b83fy6

For signals of equal length, the "Band" window is equivalent to the "SlantedBand" window:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-ec6w55

https://wolfram.com/xid/0hyzokcy3pp7qs2i-hht6a8

Options (4)Common values & functionality for each option
DistanceFunction (3)
With Boolean sequences, WarpingCorrespondence uses MatchingDissimilarity:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-1ofaka

https://wolfram.com/xid/0hyzokcy3pp7qs2i-6teu7z


https://wolfram.com/xid/0hyzokcy3pp7qs2i-dh6s7c

Find correspondences between two sequences using different distance functions:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-dui064

https://wolfram.com/xid/0hyzokcy3pp7qs2i-9y0te

In case of one-dimensional signals, some distance functions are equivalent:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-ta5zbe
Euclidean, Manhattan, and the chessboard distance are always the same:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-w8fyrf

Normalized Euclidean distance and correlation distance are the same:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-f79u0n

For Boolean data, matching dissimilarity and binary distance are the same:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-cb00zk

https://wolfram.com/xid/0hyzokcy3pp7qs2i-oemoud

Method (1)
Compare the result of full search to a flexible search:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-tsa1q2

https://wolfram.com/xid/0hyzokcy3pp7qs2i-lght1c


https://wolfram.com/xid/0hyzokcy3pp7qs2i-1sc0d0


https://wolfram.com/xid/0hyzokcy3pp7qs2i-1hv34p

Applications (2)Sample problems that can be solved with this function
Visualize the time warping correspondence by drawing lines between corresponding points:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-8lmiug

https://wolfram.com/xid/0hyzokcy3pp7qs2i-dr3cn9

https://wolfram.com/xid/0hyzokcy3pp7qs2i-j9hm8z


https://wolfram.com/xid/0hyzokcy3pp7qs2i-f0ouli

Compare the first quarter of 2017 of the HPQ stock prices with historical data from 2010 to 2016:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-db67wv

https://wolfram.com/xid/0hyzokcy3pp7qs2i-wp1fwm
Find the best matching subsequence of historical data:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-becyuh
Detect the historical interval most similar to quarter one of 2017:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-clbw3s

Visually compare recent data and the best historical match:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-oc9qag

Predict the stock prices for the next 30 days based on historical data:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-1rozx7

Properties & Relations (7)Properties of the function, and connections to other functions
The two sequences need not have the same length:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-rk7mnt

The warping path of two equal sequences goes along a diagonal line:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-87tyjr

Smaller values of the search window radius emphasize speed of computation:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-5wsjro

https://wolfram.com/xid/0hyzokcy3pp7qs2i-fk7c5a


https://wolfram.com/xid/0hyzokcy3pp7qs2i-o5juew

There may be a tradeoff with quality of the computation:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-qnpcml

When computing the full correspondence, WarpingCorrespondence is symmetric:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-cs6o1

The function is not symmetric when matching subsequences:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-iy67lb

Adding to or subtracting from values of one sequence may result in a different correspondence:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-qg9yrx

Adding to or subtracting from both sequences will not affect the result when distance function is induced by a norm (translation invariant):

https://wolfram.com/xid/0hyzokcy3pp7qs2i-89sq0i
This is true for Euclidean, Manhattan, and some more:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-1tf955

Using distance functions that are not translation invariant may produce different correspondence:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-guni08

Relation with WarpingDistance:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-3sys6h

https://wolfram.com/xid/0hyzokcy3pp7qs2i-jgscus
Find the time warped sequences using the correspondence:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-togrw4
WarpingDistance gives the sum of all the distances between corresponding elements:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-16tgnp

Possible Issues (3)Common pitfalls and unexpected behavior
All elements in the two sequences must be commensurate:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-ide6e5


Elements in the two sequences should be of the same type:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-zzi3rm


If the specified window is too narrow to find a correspondence, a larger window is automatically used:

https://wolfram.com/xid/0hyzokcy3pp7qs2i-ybs66a


Wolfram Research (2016), WarpingCorrespondence, Wolfram Language function, https://reference.wolfram.com/language/ref/WarpingCorrespondence.html.
Text
Wolfram Research (2016), WarpingCorrespondence, Wolfram Language function, https://reference.wolfram.com/language/ref/WarpingCorrespondence.html.
Wolfram Research (2016), WarpingCorrespondence, Wolfram Language function, https://reference.wolfram.com/language/ref/WarpingCorrespondence.html.
CMS
Wolfram Language. 2016. "WarpingCorrespondence." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/WarpingCorrespondence.html.
Wolfram Language. 2016. "WarpingCorrespondence." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/WarpingCorrespondence.html.
APA
Wolfram Language. (2016). WarpingCorrespondence. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/WarpingCorrespondence.html
Wolfram Language. (2016). WarpingCorrespondence. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/WarpingCorrespondence.html
BibTeX
@misc{reference.wolfram_2025_warpingcorrespondence, author="Wolfram Research", title="{WarpingCorrespondence}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/WarpingCorrespondence.html}", note=[Accessed: 21-May-2025
]}
BibLaTeX
@online{reference.wolfram_2025_warpingcorrespondence, organization={Wolfram Research}, title={WarpingCorrespondence}, year={2016}, url={https://reference.wolfram.com/language/ref/WarpingCorrespondence.html}, note=[Accessed: 21-May-2025
]}