AI Glossary · Letter D

Dynamic Time Warping.

An algorithm that measures similarity between two time series by finding the optimal alignment between them, allowing comparisons between sequences that differ in speed, timing, or length. For agencies analyzing campaign performance patterns, dynamic time warping enables comparisons that standard correlation measures miss because the patterns occur at different times across different markets or channels.

Also known as DTW, time series alignment, temporal sequence matching

What it is

A working definition of dynamic time warping.

Dynamic time warping computes the similarity between two sequences by finding the optimal elastic alignment: it can stretch or compress one sequence to align with the other, matching points based on similarity of value rather than simultaneity of timing. A standard Euclidean distance measure between two time series would penalize a pattern that occurs one week later in one market than another as dissimilar. Dynamic time warping would recognize the same underlying pattern and score the sequences as highly similar despite the timing difference.

The algorithm works by constructing a cost matrix that represents the cost of aligning every point in one sequence with every point in the other, then finding the minimum-cost path through that matrix using dynamic programming. Constraints on how far the warping path can deviate from the diagonal, called the Sakoe-Chiba band, control how much timing flexibility is allowed, trading alignment accuracy against computational cost.

DTW originated in speech recognition, where speakers say the same words at different speeds, and has been applied across time series domains including financial market analysis, manufacturing quality control, and genomics. In machine learning, it can serve as a distance metric for clustering and classification of temporal data, grouping sequences by their underlying pattern regardless of timing differences.

Why ad agencies care

Why dynamic time warping might matter more in agency work than in most industries.

Campaign performance patterns repeat across markets and channels but rarely with identical timing. A seasonal purchase spike that peaks in week four of the holiday season in one market may peak in week six in another. A working ad agency that uses standard correlation to compare these patterns concludes they are unrelated. One that uses dynamic time warping recognizes the same underlying consumer behavior expressed with a timing offset, and builds strategy accordingly.

It enables pattern-based campaign forecasting across markets. If dynamic time warping can identify that a new market’s campaign trajectory closely matches the historical trajectory of a proven market, adjusted for timing, the historical outcome data from the matched market can inform the new market’s expected performance range. This is a more principled basis for cross-market forecasting than regression on aggregate historical averages.

Multi-channel pattern alignment uses the same logic. Brand awareness lift from an out-of-home campaign typically manifests in paid search volume days or weeks after the OOH exposure, not simultaneously. Standard attribution that requires simultaneous or short-window correlation misses this relationship. DTW can identify the aligned signal across channels with different latency profiles.

It surfaces early-stage campaign anomalies. Monitoring a live campaign’s performance trajectory against historical benchmarks using DTW identifies divergence from the expected pattern early, accounting for the fact that the expected pattern may be shifted in timing relative to prior campaigns. This enables faster diagnosis of underperformance than waiting for cumulative metrics to diverge from plan.

In practice

What dynamic time warping looks like inside a working ad agency.

An agency manages retail campaigns for a national brand across 12 regional markets with different peak seasonal timing. A standard correlation analysis of weekly revenue lift across markets produces low correlations and the conclusion that regional campaigns are behaving independently. A dynamic time warping analysis of the same data, allowing for timing alignment of up to three weeks, reveals that eleven of twelve markets follow the same underlying three-phase campaign response pattern, with a shift in peak timing correlated with regional climate patterns. The insight leads the agency to restructure the national campaign as a phased regional rollout timed to each market’s peak rather than simultaneous national activation, producing a measurable improvement in revenue lift per campaign dollar.

Build the analytical capabilities that surface what standard metrics miss through The Creative Cadence Workshop.

The generative AI foundations module of the workshop covers how to apply analytical techniques that match the complexity of the patterns agencies actually need to find in campaign and customer data.