For Developers

What Is the Importance of Dynamic Time Warping?

Importance of Dynamic Time Warping

Dynamic Time warping (DTW) is a method to calculate the optimal matching between two usually temporal sequences that failed to sync up perfectly. It compares the time series data dynamically that results from the plethora of natural and man-made time-series events occurring worldwide. The list can include temperature, school grades, kinetics, kinematic variables, and other variables.

It was originally used to compare distinct speech patterns. But, in the present era, it finds applications in domains like the financial markets, data mining, speech recognition, and others. We observed its significant use in data mining, where it measures the distance between the two time series. It has also coped with different speeds and time deformations linked with time-dependent data automatically.

In this article, we are going to dig deep into the importance of dynamic time warping by considering its different applications and examples.

Plan an effective marketing strategy

Let’s understand how the dynamic time warping algorithms help businesses plan a better marketing campaign strategy for brilliant results.

The Problem

Let’s consider a business that ran a marketing campaign for one year (Jan 2019 - Jan 2020) in a particular market. They termed it an ideal market because of the highly successful output involving incremental leads.

The business plans to run the same campaign in the new markets because of its highly successful results. However, they were unsure about the ideal markets for their marketing campaign. The cost concern stretching over the period of one year also added to the second thoughts.

The dilemma was to look for an approach that would help in identifying which market was an ideal market for the business so that the same marketing campaign could bring the same results at the end of the year.

The Solution

Dynamic time warping (DTW) helped the business in recognizing which market meets the status of the ideal market. Here’s how the issue was dealt with and the solution followed.

The marketing campaign that ran successfully from Jan 2019 to Jan 2020 was taken into consideration for 6 other prospect or candidate markets for the same marketing campaign.

The leads and campaign data was available for these six markets for a period of Feb 2020 to July 2020. Later, this data from candidate markets was compared with the ideal market using the dynamic time warping algorithm.

MarketMarketing Campaign durationDTW distance
Ideal MarketJan 2019 - Jan 2020130
Candidate market AFeb 2020 - July 2020143
Candidate market BFeb 2020 - July 2020132
Candidate market CFeb 2020 - July 2020136
Candidate market DFeb 2020 - July 2020155
Candidate market EFeb 2020 - July 2020138
Candidate market FFeb 2020 - July 2020144

Note: The DTW distance refers to the distance between two-time series or arrays with distinct lengths.


After utilizing the dynamic time warping algorithm on the data of the candidate market, the candidate markets that had the lowest distance to the ideal market were selected for implementation of the marketing campaign.

MarketMarketing Campaign durationDTW distance
Ideal MarketJan 2019 - Jan 2020130
Candidate market AFeb 2020 - July 2020143
Candidate market BFeb 2020 - July 2020132
Candidate market CFeb 2020 - July 2020136
Candidate market DFeb 2020 - July 2020155
Candidate market EFeb 2020 - July 2020135
Candidate market FFeb 2020 - July 2020144

These were the candidate markets B, C and E. Only three out of the six candidate markets were considered, showing similar results to that of the ideal market. And the business continued to start the marketing campaign for the three shortlisted markets.

This way, instead of running the campaign on all the candidate markets, the business was able to use their investment precisely with the results from the dynamic time warping algorithm.

Later, the business was able to incur incremental leads of 5%, 9%, and 6% from the candidate markets B, C, and E respectively. The solution from DTW helped the business in netting a greater number of leads by correctly identifying the markets similar to its ideal market, thereby cutting down the cost of investment in marketing.

Pattern similarity in gait research

Biomechanics includes the academic focus on human movements and time series data such as kinetic, kinematics variables, and spatiotemporal variables that are analyzed frequently to describe and explain human movement. To put it simply, gait research is a systematic approach to studying human motion using the brain and the eye of the observer.

In such research, evaluating the pattern similarity is a challenging task. The visual method may be convenient, but meeting the objectives of the study causes a compromise in the process. For instance, if one has to identify the direction and degree to which the left and right foot of a person in gait diverge from each other, the results are better attained by analyzing the pattern similarity of time series data using mathematical and statistical calculation.

Let’s understand it with a practical example to discover how dynamic time warping can be helpful.

Let’s consider 16 participants in this study in which we have an equal number of males and females. The below-given table illustrates the anthropometric data of the participants.

SexAge (yr)Height (cm)Weight (kg)

In this case, we would use three conditions to find the optimal alignment. These are listed below.

Conditions to find the optimal alignment.webp

In the above conditions,

  • p = The path discovered by dynamic time warping algorithm
  • c = The local cost involved in the warping path
  • m, n = The index number of the found warping path
  • L = Warping path maximum length
  • x, y = Parameters representing sequence data

The optimum walking path is discovered by transforming two sequences into a matrix. Further, it calculates the distinct value of each element of two sequences, which we refer to as local cost that helps us in finding the optimal warping path.

Note: The smallest sum of these local costs defines the optimal warping path and the sum of local costs is called the global cost.

Here’s how you can find it mathematically.

dynamic time warping.webp

In the above given mathematical formulations, d represents the distance between every element of the two sequences. γ represents the distance accumulated of the warping path. So when the difference between two sequences is null, the resulting warping path comes as the diagonal of the matrix.

However, the symmetry index is used traditionally for evaluating the similarity in gait research. It is done using the following formula.

Mathematical formula to calculate symmetry index.webp

For a value of SI < 10%, the symmetry is accepted.

In the study that we have considered, we will compare the results of the symmetry index and dynamic time warping.

The results achieved from the implementation of the data into DTW and SI gave rise to the following result.

example of dynamic time warping.webp

Code source

Here, the picture on the left shows the alignment and warping path of data sequences when we compare the left and right foot evaluations to those similar in SI and DTW.

Another case where the evaluations were non-similar in the case of SI and DTW showed a different picture.

implementation of the data into dynamic time warping.webp

Another case also came into the picture where the evaluations were similar in SI but were non-similar in DTW, as given below.

derivative dynamic time warping.webp

This study was done to understand the effectiveness of dynamic time warping in gait research. As per the results achieved, DTW has confirmed its applicability for gait research by showing different results from SI which is a basic test to test the similarity of gait. To put it simply, the results achieved have pointed out the fact that dynamic time warping can be used for similarity tests of gait research.


It’s no secret that a dynamic time warping algorithm is a powerful distance metric to have in one’s toolbox. It comes in handy when one works with two non-linear sequences, exceptionally when one of them is a shrunk or non-linear version of the other. From comparing the stock trading data over similar time frames to accurately calculating the speed of the walker, it is a great technique that data scientists and data analysts must be familiar with in order to work with time series data.


  • Author

    Srishti Chaudhary

    Srishti is a competent content writer and marketer with expertise in niches like cloud tech, big data, web development, and digital marketing. She looks forward to grow her tech knowledge and skills.

Frequently Asked Questions

Dynamic time warping is an artificial intelligence technique that takes key inputs of varying time speeds and unequal lengths to normalize and compare them.

Soft DTW refers to the differential loss function that allows the use of gradient-based algorithms for dynamic time warping.

Time series allows you to identify the factors that affect distinct variables from time to time.

View more FAQs


What's up with Turing? Get the latest news about us here.


Know more about remote work.
Checkout our blog here.


Have any questions?
We'd love to hear from you.

Hire remote developers

Tell us the skills you need and we'll find the best developer for you in days, not weeks.

Hire Developers