gives the canonical time warping (CTW) distance between sequences s1 and s2.


uses init as the initial correspondence between the two sequences.


uses a window win for local search.

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 s1ni and s2mi 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:
  • Automatica full search
    ra 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:
  • DistanceFunctionAutomaticdistance function used in dynamic time warping
    MaxIterationsAutomaticmaximal number of iterations
    MethodAutomaticthe 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"Automaticdimensions after projection
    "EnergyThreshold"Automaticfraction of "energy" to be kept
    "Lambdas"Automaticregularization values
    "MatchingIntervals"Automaticwhether to match the query to full or part of reference
  • Possible settings for the "MatchingIntervals" option include:
  • Automatica full match
    "Flexible"flexible at both ends
    "FlexibleEnd"flexible only at the end of the interval


open all close all

Basic Examples  (2)

Find the canonical time warping distance of two scalar sequences:

Click for copyable input

Find the canonical time warping distance between a 3D path and a 2D line segment:

Click for copyable input

Scope  (9)

Options  (2)

Applications  (1)

Properties & Relations  (1)

Introduced in 2016