AI Tools Free

Dynamic Time Warping (DTW) Calculator

Compute the exact **Dynamic Time Warping (DTW)** distance, normalized per-step cost, optimal alignment path `(i, j)`, and accumulated dynamic-programming cost matrix `D(i, j)` between two numeric sequences of equal or unequal length.

Free to useNo sign-upRuns in your browser
Enter your details

Enter the inputs, then select Calculate DTW Distance & Path.

First numeric sequence X = [x_1, x_2, ..., x_n] (up to 150 points).

Second numeric sequence Y = [y_1, y_2, ..., y_m] (can have different length from X).

Select how local point-to-point cost is accumulated along the warping path.

Set w = 0 for unconstrained exact DTW, or w >= |n − m| to restrict warping to |i − j| <= w.

Your result
Enter your details

Result will appear here

How the Dynamic Time Warping Calculator Works

Paste two numeric series of any length (up to 150 observations each) to run the exact O(n×m) dynamic programming solver.

D(i, j) = c(x_i, y_j) + min( D(i−1, j), D(i, j−1), D(i−1, j−1) ) subject to |i − j| ≤ w (when w > 0); Normalized Cost = D(n, m) / K, where K is the number of aligned steps in the optimal warping path.

Computes exact O(n×m) dynamic programming alignment satisfying boundary ((1,1) to (n,m)), monotonicity, and step-continuity constraints, and compares DTW against lock-step Euclidean/Manhattan distance.

Dynamic Time Warping (DTW) Calculator workflow overview
Workflow overview for Dynamic Time Warping (DTW) Calculator.

Dynamic Time Warping (DTW) Metrics & Recurrence Reference Table

Summary of local cost options, dynamic programming recurrence rules, and output metrics computed on this page.

Metric / ParameterMathematical DefinitionDefault Sample Value (`X` vs `Y`)Practical Interpretation
Local Cost `c(x_i, y_j)``|x_i − y_j|` or `(x_i − y_j)²``|x_i − y_j|` (Absolute)Point-to-point discrepancy before cumulative DP warping
DP Recurrence `D(i, j)``c(x_i,y_j) + min(D(i−1,j−1), D(i−1,j), D(i,j−1))`**`DTW = 1.00`**Minimum cumulative cost to align prefixes `X[1..i]` and `Y[1..j]`
Normalized Path Cost`DTW / K` (`K` = warping path length)**`0.1250 / step`** (`K = 8`)Average alignment error per step along the optimal path
Lock-Step Baseline`∑ |x_i − y_i|` (when `n = m`)`16.00` (vs. `1.00` DTW)Shows how much phase-shift distortion DTW removes (`93.75%` lower)

How to use Dynamic Time Warping (DTW) Calculator step by step

Enter the values for your scenario, verify the units, and run the calculation.

Enter the inputs

Start by entering the required fields in the Dynamic Time Warping (DTW) Calculator form above.

Dynamic Time Warping (DTW) Calculator step 1: Enter the inputs
Step 1 workflow overview for Dynamic Time Warping (DTW) Calculator.

Verify units and assumptions

Match each value to the unit or format shown next to the input box before running the calculation.

Dynamic Time Warping (DTW) Calculator step 2: Verify units and assumptions
Step 2 workflow overview for Dynamic Time Warping (DTW) Calculator.

Run and export your result

Select Calculate DTW Distance & Path, inspect the primary metric and breakdown cards, then use Copy result or Download result.txt.

Dynamic Time Warping (DTW) Calculator step 3: Run and export your result
Step 3 workflow overview for Dynamic Time Warping (DTW) Calculator.

Worked examples for Dynamic Time Warping (DTW) Calculator

Compare baseline and alternative runs for Dynamic Time Warping (DTW) Calculator before exporting the result.

Baseline example

Calculate Dynamic Time Warping (DTW) distance and optimal alignment path between two time series in your browser. Supports absolute, squared, and root-squared costs plus Sakoe-Chiba window band.

Dynamic Time Warping (DTW) Calculator example 1: Baseline example
Worked example 1 for Dynamic Time Warping (DTW) Calculator.

Comparison scenario

D(i, j) = c(x_i, y_j) + min( D(i−1, j), D(i, j−1), D(i−1, j−1) ) subject to |i − j| ≤ w (when w > 0); Normalized Cost = D(n, m) / K, where K is the number of aligned steps in the optimal warping path.

Dynamic Time Warping (DTW) Calculator example 2: Comparison scenario
Worked example 2 for Dynamic Time Warping (DTW) Calculator.

Boundary check before exporting

Computes exact O(n×m) dynamic programming alignment satisfying boundary ((1,1) to (n,m)), monotonicity, and step-continuity constraints, and compares DTW against lock-step Euclidean/Manhattan distance.

Dynamic Time Warping (DTW) Calculator example 3: Boundary check before exporting
Worked example 3 for Dynamic Time Warping (DTW) Calculator.

How to interpret the Dynamic Time Warping (DTW) Calculator output

Review the calculated output alongside your entered parameters and unit conventions.

Computes exact O(n×m) dynamic programming alignment satisfying boundary ((1,1) to (n,m)), monotonicity, and step-continuity constraints, and compares DTW against lock-step Euclidean/Manhattan distance.

How to interpret Dynamic Time Warping (DTW) Calculator results
Result interpretation guide for Dynamic Time Warping (DTW) Calculator.

DTW Analysis Verification Checklist

Check these three items when interpreting DTW distances.

D(i, j) = c(x_i, y_j) + min( D(i−1, j), D(i, j−1), D(i−1, j−1) ) subject to |i − j| ≤ w (when w > 0); Normalized Cost = D(n, m) / K, where K is the number of aligned steps in the optimal warping path. Computes exact O(n×m) dynamic programming alignment satisfying boundary ((1,1) to (n,m)), monotonicity, and step-continuity constraints, and compares DTW against lock-step Euclidean/Manhattan distance.

Scope limits and assumptions for Dynamic Time Warping (DTW) Calculator
Assumptions and input boundaries for Dynamic Time Warping (DTW) Calculator.

Dynamic Time Warping (DTW) Calculator: common questions

Answers about using Dynamic Time Warping (DTW) Calculator and understanding its results.

Why is Dynamic Time Warping (DTW) better than Euclidean distance for shifted time series?

Lock-step Euclidean or Manhattan distance compares index i of series X strictly against the same index i of series Y (and cannot compare series of unequal length). If two identical waveforms are shifted by even a single time step—such as X = [1, 3, 4, 9, 8, 2, 1] and Y = [1, 1, 3, 4, 9, 8, 2]—lock-step distance reports a large error (16.0), whereas DTW nonlinearly stretches the time axis and finds a near-zero alignment cost (1.0).

What are the three mathematical constraints on a valid DTW warping path?

A standard DTW warping path W = [w_1, ..., w_K] must satisfy: (1) Boundary condition: start at w_1 = (1, 1) and end at w_K = (n, m); (2) Continuity: each step moves by at most 1 index in i and j, i.e., (i_k − i_{k−1}, j_k − j_{k−1}) ∈ {(1,0), (0,1), (1,1)}; and (3) Monotonicity: indices never move backward in time (i_k ≥ i_{k−1} and j_k ≥ j_{k−1}).

What does the Sakoe-Chiba window bandwidth w do?

The Sakoe-Chiba band constrains the warping path so that index i in series X can only align with index j in series Y if |i − j| ≤ max(w, |n − m|). Setting a locality window prevents pathological warping (where a single point in X stretches across dozens of points in Y) and speeds up computation.

What is the difference between raw DTW distance and Normalized DTW Cost per step?

Raw DTW distance sums the local costs across all K steps of the warping path, so longer sequences naturally accumulate larger raw sums. Dividing the total DTW cost by the warping path length K yields the Normalized Path Cost per aligned step, allowing fair similarity comparisons across pairs of different lengths.

Try your own values

Choose another tool for your next calculation, conversion, or text task.

Calculate DTW Distance & Path