English

Approximating Dynamic Time Warping Distance Between Run-Length Encoded Strings

Data Structures and Algorithms 2022-07-05 v1

Abstract

Dynamic Time Warping (DTW) is a widely used similarity measure for comparing strings that encode time series data, with applications to areas including bioinformatics, signature verification, and speech recognition. The standard dynamic-programming algorithm for DTW takes O(n2)O(n^2) time, and there are conditional lower bounds showing that no algorithm can do substantially better. In many applications, however, the strings xx and yy may contain long runs of repeated letters, meaning that they can be compressed using run-length encoding. A natural question is whether the DTW-distance between these compressed strings can be computed efficiently in terms of the lengths kk and \ell of the compressed strings. Recent work has shown how to achieve O(k2+k2)O(k\ell^2 + \ell k^2) time, leaving open the question of whether a near-quadratic O~(k)\tilde{O}(k\ell)-time algorithm might exist. We show that, if a small approximation loss is permitted, then a near-quadratic time algorithm is indeed possible: our algorithm computes a (1+ϵ)(1 + \epsilon)-approximation for DTW(x,y)DTW(x, y) in O~(k/ϵ3)\tilde{O}(k\ell / \epsilon^3) time, where kk and \ell are the number of runs in xx and yy. Our algorithm allows for DTWDTW to be computed over any metric space (Σ,δ)(\Sigma, \delta) in which distances are O(log(n))O(log(n))-bit integers. Surprisingly, the algorithm also works even if δ\delta does not induce a metric space on Σ\Sigma (e.g., δ\delta need not satisfy the triangle inequality).

Keywords

Cite

@article{arxiv.2207.00915,
  title  = {Approximating Dynamic Time Warping Distance Between Run-Length Encoded Strings},
  author = {Zoe Xi and William Kuszmaul},
  journal= {arXiv preprint arXiv:2207.00915},
  year   = {2022}
}

Comments

A shorter version of this paper will be published in ESA 2022

R2 v1 2026-06-24T12:12:11.116Z