---
title: "WarpingCorrespondence"
language: "en"
type: "Symbol"
summary: "WarpingCorrespondence[s1, s2] gives the time warping (DTW) similarity path between sequences s1 and s2. WarpingCorrespondence[s1, s2, win] uses a window specified by win for local search."
keywords: 
- dtw similarity
- dtw distance
- dynamic time warping
- time warping
- time warping similarity
- time warping distance
- time warping correspondence
- sequence alignment
- similarity in shape of time series
- distance in shape of time series
- time series alignment
- Sakoe-Chuba Band
- similar time series
- similar vectors
- align sequences
- align lists
- dynamic programming
- ctw
- ddtw
- d-dtw
- derivative dtw
canonical_url: "https://reference.wolfram.com/language/ref/WarpingCorrespondence.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Sequence Alignment & Comparison"
    link: "https://reference.wolfram.com/language/guide/SequenceAlignmentAndComparison.en.md"
related_functions: 
  - 
    title: "WarpingDistance"
    link: "https://reference.wolfram.com/language/ref/WarpingDistance.en.md"
  - 
    title: "CanonicalWarpingCorrespondence"
    link: "https://reference.wolfram.com/language/ref/CanonicalWarpingCorrespondence.en.md"
  - 
    title: "SequenceAlignment"
    link: "https://reference.wolfram.com/language/ref/SequenceAlignment.en.md"
  - 
    title: "LongestOrderedSequence"
    link: "https://reference.wolfram.com/language/ref/LongestOrderedSequence.en.md"
---
# WarpingCorrespondence

WarpingCorrespondence[s1, s2] gives the time warping (DTW) similarity path between sequences s1 and s2.

WarpingCorrespondence[s1, s2, win] uses a window specified by win for local search.

## 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 $\sum _{i=1}^k d\left(s_1\left[\left[n_i\right]\right],s_2\left[\left[m_i\right]\right]\right)$ 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:

|     |     |     |
| --- | --- | --- |
| [image] | Automatic | a full search |
| [image] | r   | a slanted band window of radius $r$ |
| [image] | {"SlantedBand", r} | a slanted band window of radius $r$ |
| [image] | {"Band", r} | band window of radius $r$ (Sakoe-Chiba) |
| [image] | {"Parallelogram", a} | parallelogram window placed at origin with slopes $a$ and $1/a$ (Itakura) |

* A smaller $r$ typically gives a faster but less optimal result. If $\max \left(\underline{\text{Length}}\left[s_1\right],\underline{\text{Length}}\left[s_2\right]\right)\leq 2 r +1$, then $r$ 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 ``DistanceFunction -> d`` 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 (26)

### Basic Examples (1)

Find the time warping correspondence between two sequences:

```wl
In[1]:=
s1 = {0, 0, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6};
s2 = {1, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7};

In[2]:= {n, m} = WarpingCorrespondence[s1, s2]

Out[2]= {{1, 2, 3, 4, 5, 6, 7, 8, 8, 8, 9, 10, 10, 10, 11, 12, 12, 12, 12, 13, 13, 13}, {1, 1, 1, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}}
```

Plot the correspondence between indices:

```wl
In[3]:= ListLinePlot[{n, m}\[Transpose]]

Out[3]= [image]
```

Find the time warped versions:

```wl
In[4]:= w1 = s1[[n]]

Out[4]= {0, 0, 1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6}

In[5]:= w2 = s2[[m]]

Out[5]= {1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7}
```

The warped versions are approximately equal:

```wl
In[6]:= ListLinePlot[{w1, w2}\[Transpose]]

Out[6]= [image]
```

### Scope (9)

#### Data (6)

Find the time warping correspondence between two real-valued vectors:

```wl
In[1]:= WarpingCorrespondence[{Pi, E, E + Pi, -Pi / E}, {Pi ^ E, E - Pi, -E * Pi, E ^ Pi}]//TextGrid

Out[1]=
|   |   |   |   |   |
| - | - | - | - | - |
| 1 | 2 | 3 | 4 | 4 |
| 1 | 2 | 2 | 3 | 4 |
```

---

Find the time warping correspondence between two sequences of vectors:

```wl
In[1]:=
s1 = {{11, 12}, {13, 14}, {15, 16}};
s2 = {{12, 13}, {14, 15}};

In[2]:= WarpingCorrespondence[s1, s2]//TextGrid

Out[2]=
|   |   |   |
| - | - | - |
| 1 | 2 | 3 |
| 1 | 1 | 2 |
```

---

Find the time warping correspondence between two Boolean vectors:

```wl
In[1]:= s1 = PrimeQ /@ Range[1, 20]

Out[1]= {False, True, True, False, True, False, True, False, False, False, True, False, True, False, False, False, True, False, True, False}

In[2]:= s2 = CoprimeQ[#, 6]& /@ Range[1, 20]

Out[2]= {True, False, False, False, True, False, True, False, False, False, True, False, True, False, False, False, True, False, True, False}

In[3]:= WarpingCorrespondence[s1, s2]\[Transpose]//ListLinePlot

Out[3]= [image]
```

---

Sequences of Boolean-valued vectors:

```wl
In[1]:=
s1 = {{True, True, True}, {False, True, True}, {False, False, True}, {True, True, False}, {False, True, True}};
s2 = {{True, True, True}, {True, False, True}, {False, True, True}, {False, True, True}};

In[2]:= WarpingCorrespondence[s1, s2]//TextGrid

Out[2]=
|   |   |   |   |   |
| - | - | - | - | - |
| 1 | 2 | 3 | 4 | 5 |
| 1 | 1 | 2 | 3 | 4 |
```

---

Sequences of quantities with compatible units:

```wl
In[1]:=
s1 = QuantityArray[{1, 2.5, 4}, "Decimeters"];
s2 = {Quantity[0.1, "Kilometers"], Quantity[200, "Inches"]};

In[2]:= WarpingCorrespondence[s1, s2]//TextGrid

Out[2]=
|   |   |   |
| - | - | - |
| 1 | 2 | 3 |
| 1 | 2 | 2 |
```

---

Two-dimensional quantity arrays:

```wl
In[1]:= s1 = QuantityArray[{{1, 2.5}, {4, 5}, {5, 4}}, {"Seconds", "Minutes"}]

Out[1]=
QuantityArray[StructuredArray`StructuredData[{3, 2}, {{{1, 2.5}, {4, 5}, {5, 4}}, 
   {"Seconds", "Minutes"}, {{1}, {2}}}]]

In[2]:= s2 = Table[Quantity[(i + j) / 60, "Hours"], {i, 5}, {j, 2}]

Out[2]= {{Quantity[1/30, "Hours"], Quantity[1/20, "Hours"]}, {Quantity[1/20, "Hours"], Quantity[1/15, "Hours"]}, {Quantity[1/15, "Hours"], Quantity[1/12, "Hours"]}, {Quantity[1/12, "Hours"], Quantity[1/10, "Hours"]}, {Quantity[1/10, "Hours"], Quantity[7/60, "Hours"]}}

In[3]:= WarpingCorrespondence[s1, s2]//TextGrid

Out[3]=
|   |   |   |   |   |
| - | - | - | - | - |
| 1 | 2 | 2 | 2 | 3 |
| 1 | 2 | 3 | 4 | 5 |
```

#### Search Window (3)

By default, the search is not locally constrained:

```wl
In[1]:=
s1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
s2 = {1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 5, 5, 6, 7};

In[2]:= WarpingCorrespondence[s1, s2]//TextGrid

Out[2]=
|   |   |   |   |   |   |   |   |   |    |    |    |    |    |    |    |    |    |    |    |
| - | - | - | - | - | - | - | - | - | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- |
| 1 | 1 | 1 | 1 | 1 | 1 | 2 | 3 | 4 | 5  | 5  | 5  | 6  | 7  | 8  | 9  | 10 | 11 | 12 | 13 |
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 14 | 14 | 14 | 14 | 14 | 14 |

In[3]:= WarpingCorrespondence[s1, s2] == WarpingCorrespondence[s1, s2, Automatic]

Out[3]= True
```

Specify a radius for the search window:

```wl
In[4]:= WarpingCorrespondence[s1, s2, 1]//TextGrid

Out[4]=
|   |   |   |   |   |   |   |   |   |    |    |    |    |    |    |
| - | - | - | - | - | - | - | - | - | -- | -- | -- | -- | -- | -- |
| 1 | 1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8  | 9  | 10 | 11 | 12 | 13 |
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 14 |
```

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

```wl
In[5]:= WarpingCorrespondence[s1, s2, 2]//TextGrid

Out[5]=
|   |   |   |   |   |   |   |   |   |    |    |    |    |    |    |    |
| - | - | - | - | - | - | - | - | - | -- | -- | -- | -- | -- | -- | -- |
| 1 | 1 | 1 | 1 | 2 | 3 | 4 | 5 | 6 | 7  | 8  | 9  | 10 | 11 | 12 | 13 |
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 14 | 14 |
```

---

Use a band of radius 1:

```wl
In[1]:=
s1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
s2 = {1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

In[2]:= WarpingCorrespondence[s1, s2, {"Band", 1}]//TextGrid

Out[2]=
|   |   |   |   |   |   |   |   |   |    |    |    |    |    |
| - | - | - | - | - | - | - | - | - | -- | -- | -- | -- | -- |
| 1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  | 10 | 11 | 12 | 13 |
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
```

Use a parallelogram of slope 3:

```wl
In[3]:= WarpingCorrespondence[s1, s2, {"Parallelogram", 3}]//TextGrid

Out[3]=
|   |   |   |   |   |   |   |   |   |    |    |    |    |    |    |    |    |
| - | - | - | - | - | - | - | - | - | -- | -- | -- | -- | -- | -- | -- | -- |
| 1 | 1 | 1 | 1 | 2 | 2 | 3 | 4 | 5 | 6  | 7  | 8  | 9  | 10 | 11 | 12 | 13 |
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 13 | 14 | 14 | 14 |
```

---

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

```wl
In[1]:=
s1 = RealDigits[Pi, 10, 25]//First;
s2 = RealDigits[E, 10, 25]//First;

In[2]:= WarpingCorrespondence[s1, s2, {"Band", 3}] == WarpingCorrespondence[s1, s2, {"SlantedBand", 3}]

Out[2]= True
```

### Options (4)

#### DistanceFunction (3)

With Boolean sequences, ``WarpingCorrespondence`` uses ``MatchingDissimilarity`` :

```wl
In[1]:=
s1 = {{True, False, False}, {True, True, False}, {True, False, False}, {True, False, False}, {False, False, False}};
s2 = {{False, False, False}, {True, True, False}, {False, True, False}, {False, True, False}, {True, False, True}, {False, False, False}, {True, False, False}};

In[2]:= WarpingCorrespondence[s1, s2]

Out[2]= {{1, 2, 2, 2, 3, 4, 5}, {1, 2, 3, 4, 5, 6, 7}}

In[3]:= WarpingCorrespondence[s1, s2, DistanceFunction -> MatchingDissimilarity] == %

Out[3]= True
```

---

Find correspondences between two sequences using different distance functions:

```wl
In[1]:=
v1 = {50, 60, 70, 71, 71, 73, 75, 80, 80, 80, 78, 76, 75, 73, 71, 71, 71, 73, 75, 76, 76, 68, 76, 76, 75, 73};
v2 = {61, 62, 62, 64, 69, 69, 73, 75, 79, 80, 79, 78, 76, 73, 72, 71, 70, 70, 69, 69, 69, 71, 73, 75, 76};
distances = {EuclideanDistance, BinaryDistance, CorrelationDistance};

In[2]:= ListLinePlot[Transpose[WarpingCorrespondence[v1, v2, DistanceFunction -> #]]& /@ distances, PlotLegends -> distances]

Out[2]= [image]
```

---

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

```wl
In[1]:=
s1 = Range[10];
s2 = Range[15];
```

Euclidean, Manhattan, and the chessboard distance are always the same:

```wl
In[2]:= WarpingCorrespondence[s1, s2, DistanceFunction -> EuclideanDistance] == WarpingCorrespondence[s1, s2, DistanceFunction -> ManhattanDistance] == WarpingCorrespondence[s1, s2, DistanceFunction -> ChessboardDistance]

Out[2]= True
```

Normalized Euclidean distance and correlation distance are the same:

```wl
In[3]:= WarpingCorrespondence[s1, s2, DistanceFunction -> NormalizedSquaredEuclideanDistance] == WarpingCorrespondence[s1, s2, DistanceFunction -> CorrelationDistance]

Out[3]= True
```

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

```wl
In[4]:=
s1  = {True, False, True};
s2 = {False, False, True};

In[5]:= WarpingCorrespondence[s1, s2, DistanceFunction -> MatchingDissimilarity] == WarpingCorrespondence[s1, s2, DistanceFunction -> BinaryDistance]

Out[5]= True
```

#### Method (1)

Compare the result of full search to a flexible search:

```wl
In[1]:=
query = Table[{Cos[a], Sin[a]}, {a, Range[10] * Pi / 5.}];
ref = PadLeft[PadRight[query, {15, 2}], {20, 2}];

In[2]:= (openEnd = WarpingCorrespondence[ref, query, Method -> {"MatchingInterval" -> "FlexibleEnd"}])//TextGrid

Out[2]=
|   |   |   |   |   |   |   |   |   |    |    |    |    |    |    |
| - | - | - | - | - | - | - | - | - | -- | -- | -- | -- | -- | -- |
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 1 | 1 | 1 | 1 | 1 | 1 | 2 | 3 | 4 | 5  | 6  | 7  | 8  | 9  | 10 |

In[3]:= (full = WarpingCorrespondence[ref, query])//TextGrid

Out[3]=
|   |   |   |   |   |   |   |   |   |    |    |    |    |    |    |    |    |    |    |    |
| - | - | - | - | - | - | - | - | - | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- |
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 1 | 1 | 1 | 1 | 1 | 1 | 2 | 3 | 4 | 5  | 6  | 7  | 8  | 9  | 10 | 10 | 10 | 10 | 10 | 10 |
```

Visually compare the results:

```wl
In[4]:=
ListLinePlot[{openEnd\[Transpose], full\[Transpose]}, PlotLegends -> {"Relaxed DTW", "Strict DTW"}, 
	GridLines -> {Range[20], Range[10]}, PlotStyle -> {Thickness[.03], Automatic}, PlotRange -> {{0, 21}, {0, 11}}]

Out[4]= [image]
```

### Applications (2)

Visualize the time warping correspondence by drawing lines between corresponding points:

```wl
In[1]:=
timeWarpingPlot[s1_, s2_] := 
	Module[{n, m}, 
	{n, m} = WarpingCorrespondence[s1, s2];
	ListLinePlot[{s1, s2}, PlotMarkers -> Automatic, Epilog -> {RGBColor[0.560181, 0.691569, 0.194885], Line@Transpose[{{n, s1[[n]]}\[Transpose], 
{m, s2[[m]]}\[Transpose]}]}]
	];
```

Apply it to some data:

```wl
In[2]:= {s1, s2} = {{1, 2, 3, 4, 5, 9}, {11, 9, 8, 9, 12, 14}};

In[3]:= WarpingCorrespondence[s1, s2]

Out[3]= {{1, 2, 3, 4, 5, 6, 6, 6}, {1, 2, 3, 3, 3, 4, 5, 6}}

In[4]:= timeWarpingPlot[s1, s2]

Out[4]= [image]
```

---

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

```wl
In[1]:= recent = QuantityMagnitude[FinancialData["HPQ", {{2017, 1, 1}, {2017, 3, 31}}]["Values"]];
```

Get historic data:

```wl
In[2]:=
history = FinancialData["HPQ", {{2010, 1, 1}, {2016, 12, 31}}, "DateValue"];
{histDates, hist} = {history["Dates"], QuantityMagnitude[history["Values"]]};
```

Find the best matching subsequence of historical data:

```wl
In[3]:= {corrHist, corrRecent} = WarpingCorrespondence[hist, recent, Method -> {"MatchingInterval" -> "Flexible"}];
```

Detect the historical interval most similar to quarter one of 2017:

```wl
In[4]:=
{m, n} = corrHist[[{1, -1}]];
histDates[[{m, n}]]

Out[4]= {DateObject[{2014, 5, 12, 0, 0, 0.}, "Instant", "Gregorian", -6.], DateObject[{2014, 9, 3, 0, 0, 0.}, "Instant", "Gregorian", -6.]}
```

Visually compare recent data and the best historical match:

```wl
In[5]:= DateListPlot[{AssociationThread[Take[histDates[[m ;; n]], UpTo@Length[recent]], Take[recent, UpTo[n - m + 1]]], AssociationThread[histDates[[m ;; n]], hist[[m ;; n]]]}, ...]

Out[5]= [image]
```

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

```wl
In[6]:=
l = Length[recent];
colDat = ColorData[97];
offset = Last[recent] - hist[[n]];
hist30d = hist[[n ;; n + 30]];
ListLinePlot[{recent, {l + Range[31], hist30d + offset}\[Transpose], hist[[m ;; n]], {n - m + Range[31], hist30d}\[Transpose]}, ...]

Out[6]= [image]
```

### Properties & Relations (7)

The two sequences need not have the same length:

```wl
In[1]:= WarpingCorrespondence[{1, 2, 3, 4, 5}, {1, 2, 3}]

Out[1]= {{1, 2, 3, 4, 5}, {1, 2, 3, 3, 3}}
```

---

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

```wl
In[1]:=
c = WarpingCorrespondence[Range[10], Range[10]];
ListPlot[c\[Transpose]]

Out[1]= [image]
```

---

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

```wl
In[1]:=
s1 = Sin[Range[1000] / 50 * 2 * Pi];
s2 = Sin[Range[5, 1004] / 100 * 2 * Pi] + RandomReal[{-.1, .1}, 1000];

In[2]:= w1 = WarpingCorrespondence[s1, s2, 10];//AbsoluteTiming//First

Out[2]= 0.010962

In[3]:= w2 = WarpingCorrespondence[s1, s2];//AbsoluteTiming//First

Out[3]= 0.077075
```

There may be a tradeoff with quality of the computation:

```wl
In[4]:= ListLinePlot[{Legended[Transpose[w1], "r = 10"], Legended[Transpose[w2], "optimal warping"]}]

Out[4]= [image]
```

---

When computing the full correspondence, ``WarpingCorrespondence`` is symmetric:

```wl
In[1]:=
s1 = {1, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7};
s2 = {0, 0, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6};
WarpingCorrespondence[s1, s2] == Reverse@WarpingCorrespondence[s2, s1]

Out[1]= True
```

The function is not symmetric when matching subsequences:

```wl
In[2]:= WarpingCorrespondence[s1, s2, Method -> {"MatchingInterval" -> "Flexible"}] == Reverse@WarpingCorrespondence[s2, s1, Method -> {"MatchingInterval" -> "Flexible"}]

Out[2]= False
```

---

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

```wl
In[1]:=
s1 = {0, 0, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6};
s2 = {1, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7};
res1 = WarpingCorrespondence[s1, s2];res2 = WarpingCorrespondence[s1, s2 - 2];
ListLinePlot[{res1\[Transpose], res2\[Transpose]}, PlotLegends -> {"original signal", "translated signal"}]

Out[1]= [image]
```

---

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

```wl
In[1]:=
s1 = {0, 0, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6};
s2 = {1, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7};
```

This is true for Euclidean, Manhattan, and some more:

```wl
In[2]:= WarpingCorrespondence[s1, s2] == WarpingCorrespondence[s1 - 3, s2 - 3]

Out[2]= True
```

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

```wl
In[3]:=
res1 = WarpingCorrespondence[s1, s2, DistanceFunction -> BrayCurtisDistance];res2 = WarpingCorrespondence[s1 - 3, s2 - 3, DistanceFunction -> BrayCurtisDistance];
ListLinePlot[{res1\[Transpose], res2\[Transpose]}, PlotLegends -> {"original signals", "translated signals"}]

Out[3]= [image]
```

---

Relation with ``WarpingDistance`` :

```wl
In[1]:=
s1 = Sin[Range[100] / 50 * 2 * Pi];
s2 = Sin[Range[5, 104] / 100 * 2 * Pi] + RandomReal[{-.1, .1}, 100];
distance = EuclideanDistance;

In[2]:= {n, m} = WarpingCorrespondence[s1, s2, DistanceFunction -> distance];
```

Find the time warped sequences using the correspondence:

```wl
In[3]:=
l1 = s1[[n]];
l2 = s2[[m]];
```

``WarpingDistance`` gives the sum of all the distances between corresponding elements:

```wl
In[4]:= Total[MapThread[distance, {l1, l2}]] == WarpingDistance[s1, s2, DistanceFunction -> distance]

Out[4]= True
```

### Possible Issues (3)

All elements in the two sequences must be commensurate:

```wl
In[1]:= WarpingCorrespondence[{1, 2, 3}, {{1, 2}, {3, 4}, {5, 6}}]
```

WarpingCorrespondence::invarg: Expecting a real-valued numeric or boolean vector or matrix instead of {{1,2},{3,4},{5,6}}.

```wl
Out[1]= WarpingCorrespondence[{1, 2, 3}, {{1, 2}, {3, 4}, {5, 6}}]
```

---

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

```wl
In[1]:= WarpingCorrespondence[{1, 2, 3}, {True, False, True}]
```

WarpingCorrespondence::invarg: Expecting a real-valued numeric or boolean vector or matrix instead of {True,False,True}.

```wl
Out[1]= WarpingCorrespondence[{1, 2, 3}, {True, False, True}]
```

---

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

```wl
In[1]:=
s1 = {0, 0, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6};
s2 = {1, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7};
WarpingCorrespondence[s1, s2, {"Band", 1}]
```

WarpingCorrespondence::toosmallr: The specified search radius {Band,1} is too small to yield a result. Adjusting to 4.

```wl
Out[1]= {{1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 10, 10, 10, 11, 12, 12, 12, 12, 13, 13, 13}, {1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}}
```

## See Also

* [`WarpingDistance`](https://reference.wolfram.com/language/ref/WarpingDistance.en.md)
* [`CanonicalWarpingCorrespondence`](https://reference.wolfram.com/language/ref/CanonicalWarpingCorrespondence.en.md)
* [`SequenceAlignment`](https://reference.wolfram.com/language/ref/SequenceAlignment.en.md)
* [`LongestOrderedSequence`](https://reference.wolfram.com/language/ref/LongestOrderedSequence.en.md)

## Related Guides

* [Sequence Alignment & Comparison](https://reference.wolfram.com/language/guide/SequenceAlignmentAndComparison.en.md)

## History

* [Introduced in 2016 (11.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn110.en.md)