CanonicalWarpingDistance
✖
CanonicalWarpingDistance
gives the canonical time warping (CTW) distance between sequences s1 and s2.
uses init as the initial correspondence between the two sequences.
Details and Options


- Canonical time warping (CTW) iteratively performs spatial transformations and dynamic time warping on the reference sequence s1 and the query sequence s2 to find the alignment with minimal distance between sequences.
- The sequences si can be lists of numeric scalars or vectors. In contrast to dynamic time warping, elements of s1 and s2 can be of different dimensions.
- The distance is given by
, where s1〚ni〛 and s2〚mi〛 are corresponding elements, and α and β are spatial transformation matrices computed using canonical correlation analysis.
- The correspondence giving the computed distance can be obtained using CanonicalWarpingCorrespondence.
- Initial correspondence init should be given in the form of {{n1,…,nk}{{m1,…,mk}}, which provides an initial one-to-one correspondence between the elements of s1 and s2.
- 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)
- The following options are supported:
-
DistanceFunction Automatic distance function used in dynamic time warping MaxIterations Automatic maximal number of iterations Method Automatic the variant of CTW to use - For possible settings of DistanceFunction, see the reference page for WarpingDistance.
- The following options are available through Method->opts:
-
"DimensionsToKeep" Automatic dimensions after projection "EnergyThreshold" Automatic fraction of "energy" to be kept "Lambdas" Automatic regularization values "MatchingIntervals" Automatic whether to match the query to full or part of reference - Possible settings for the "MatchingIntervals" option include:
-
Automatic a full match "Flexible" flexible at both ends "FlexibleEnd" flexible only at the end of the interval
Examples
open allclose allBasic Examples (2)Summary of the most common use cases
Scope (9)Survey of the scope of standard use cases
Data (6)
Find the distance between two sequences of numerical scalars with different length:

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-4ixvux

Find the distance between two sequences of vectors:

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-cvospy

Find the distance between a sequence of scalars and a sequence of 3D points:

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-dippe4

Find the distance between two sequences of quantities with compatible units:

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-mqt072

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-g4ussc

All units are converted to base SI units:

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-bulhww

Find the distance between two sequences of quantity vectors with compatible units:

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-9hl3wz


https://wolfram.com/xid/08dsoghhr87r0bmo6erki-3zzrt4


https://wolfram.com/xid/08dsoghhr87r0bmo6erki-lyzqtd

Find the distance between a sequence of quantities and a sequence of scalars:

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-t63o31

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-sa985d

The scalars are interpreted as if they had a compatible unit from SI base units:

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-gxz9x8


https://wolfram.com/xid/08dsoghhr87r0bmo6erki-roclfe

Initial Warping (1)
By default, the shorter sequence is first warped uniformly to match the length of the longer sequence:

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-foq6y0

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-3ibbdl

Construct the initial uniform warping manually:

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-27dfdl

Search Window (2)
By default, an unconstrained search is performed:

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-75y26h

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-erqeni

Use a "SlantedBand" search window:

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-dk2bqk

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-5f7uuh

Options (2)Common values & functionality for each option
MaxIterations (2)
By default, the maximal number of iterations is 50:

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-1im7et


https://wolfram.com/xid/08dsoghhr87r0bmo6erki-rkbltr

Decreasing the maximal number of iterations may reduce the timing:

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-v65dsl

Increasing the maximal number of iterations may yield a smaller distance whenever CTW converges:

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-h18cx2

Set MaxIterations∞ to find the distance after convergence. CTW may not converge:

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-2dgbmz

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-79ywmj

Applications (1)Sample problems that can be solved with this function
Compare similarity between shapes of different countries:

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-hdgm5q

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-5bkfq

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-qjctac

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-xfdp9

Properties & Relations (1)Properties of the function, and connections to other functions
Canonical time warping is robust to spatial transformations.

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-2geypg

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-bl56vn


https://wolfram.com/xid/08dsoghhr87r0bmo6erki-ndqcb9


https://wolfram.com/xid/08dsoghhr87r0bmo6erki-ub1s52


https://wolfram.com/xid/08dsoghhr87r0bmo6erki-iain7s


https://wolfram.com/xid/08dsoghhr87r0bmo6erki-q2exbo

https://wolfram.com/xid/08dsoghhr87r0bmo6erki-gp6zdo


https://wolfram.com/xid/08dsoghhr87r0bmo6erki-11odgj

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