← Gallery Dynamic time warping — cost matrix + path

Dynamic time warping — cost matrix + path

sequence/dtw

Dynamic time warping is how you line up two takes of the same material when one of them drags or rushes — it stretches time until the two sequences match. The heatmap shows the accumulated-cost matrix D with the recovered warping path overlaid, riding the cheapest valley. Technically: X is a 2-dim ramp (40 frames) and Y duplicates frames 10–19 (known warp map), so the path must ride the zero-cost valley exactly — total cost 0, every path pair obeying the duplication map, and subsequence DTW pinning an embedded copy at its exact offset. Same asserts as examples/node/dtw.mjs (node-verified).

accumulated cost D (40×50, dark = cheap) with warping path in cyan