Skip to main content
QUICK REVIEW

[Paper Review] Approximating Dynamic Time Warping Distance Between Run-Length Encoded Strings

Zoe Xi, William Kuszmaul|arXiv (Cornell University)|Jan 1, 2022
Algorithms and Data CompressionComputer Science1 citations
TL;DR

This paper presents a near-quadratic-time (1+ε)-approximation algorithm for Dynamic Time Warping (DTW) distance between run-length encoded (RLE) strings, achieving ˜O(kℓ/ε³) time complexity where k and ℓ are the number of runs in the input strings. The method leverages geometric path decomposition and approximate distance computation in a small DAG, enabling efficient approximation even when the underlying distance function does not satisfy the triangle inequality.

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(n^2)$ time, and there are conditional lower bounds showing that no algorithm can do substantially better. In many applications, however, the strings $x$ and $y$ 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 $k$ and $\ell$ of the compressed strings. Recent work has shown how to achieve $O(k\ell^2 + \ell k^2)$ time, leaving open the question of whether a near-quadratic $ ilde{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 + ε)$-approximation for $DTW(x, y)$ in $ ilde{O}(k\ell / ε^3)$ time, where $k$ and $\ell$ are the number of runs in $x$ and $y$. Our algorithm allows for $DTW$ to be computed over any metric space $(Σ, δ)$ in which distances are $O(log(n))$-bit integers. Surprisingly, the algorithm also works even if $δ$ does not induce a metric space on $Σ$ (e.g., $δ$ need not satisfy the triangle inequality).

Motivation & Objective

  • To address the computational inefficiency of exact DTW on long strings with repeated runs, which currently requires O(k³) time for k-run RLE strings.
  • To explore whether a near-quadratic time approximation algorithm exists for DTW on RLE strings, given the conditional lower bounds on exact DTW.
  • To design a practical and efficient approximation algorithm that trades a small accuracy loss for significant speedup, especially in metric spaces with bounded or logarithmic-bit distances.
  • To extend applicability to non-metric distance functions (e.g., non-symmetric or non-triangular) while maintaining approximation guarantees.

Proposed method

  • The algorithm uses a geometric interpretation of DTW as a path through a grid, decomposing each path into components that can be approximated efficiently.
  • It introduces a distance function δε₁ that scales original distances by a (1+ε₁) factor, enabling controlled approximation while preserving bounds.
  • The method reduces the DTW approximation problem to computing pairwise distances in a small, directed acyclic graph (DAG), whose size depends on the number of distinct distance values.
  • It applies a hierarchical approximation strategy using β∗(x,y), which bounds the number of distinct distance levels, leading to a soft-O time complexity of ˜O(kℓ/ε³).
  • For Hamming space (δ(a,b) ∈ {0,1}), the time complexity improves to ˜O(kℓ/ε²) due to fewer distinct distance values.
  • The algorithm is robust to non-metric distance functions, as it does not require the triangle inequality or symmetry.

Experimental results

Research questions

  • RQ1Can a (1+ε)-approximation for DTW between RLE strings be computed in near-quadratic time, i.e., ˜O(kℓ/ε³)?
  • RQ2Is it possible to achieve such approximation without requiring the distance function to satisfy the triangle inequality or symmetry?
  • RQ3Can the algorithm be adapted to work efficiently in metric spaces with O(log n)-bit integer distances?
  • RQ4Does the approximation framework remain effective when the distance function is non-metric or non-symmetric?
  • RQ5Can the time complexity be further improved for special cases, such as Hamming space?

Key findings

  • The proposed algorithm computes a (1+ε)-approximation of DTW(x,y) in ˜O(kℓ/ε³) time for RLE strings with k and ℓ runs, respectively.
  • For Hamming space, where δ(a,b) ∈ {0,1}, the running time improves to ˜O(kℓ/ε²), reflecting reduced distance diversity.
  • The algorithm works even when the distance function δ does not satisfy the triangle inequality, making it applicable to a broader class of similarity measures.
  • The method relies on a transformation δε₁ that scales distances by (1+ε₁), enabling a chain of approximations that preserve the (1+ε) guarantee.
  • The time complexity is bounded by ˜O(kℓ/ε³) because the number of distinct δε₁ values is O(log₁₊ε₁(m+n)), which is treated as ˜O(1/ε₁) in soft-O notation.
  • The algorithm is robust and efficient, offering a significant asymptotic speedup over the exact O(k³) algorithm for RLE strings.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.