# Getting speed difference between signal comparison using Dynamic Time Warping

I understand that Dynamic Time Warping is an algorithm to find a matching between two signals with different length and speed

But is there a possible way to find the speed difference between the two signals being compared?

To clarify my question. I am working on a project to find similarity between two motions. The data being compared is in the form of Quaternion. By using DTW I was able to find the similarity/ dis-similarity between these motion signals, However I would like to know is there a way to find if one motion signal is slower/faster than the other. Ex: both motions are actually similar, but one of the motion is slower than the other

• Welcome to CS.SE! 1. Can you define what you mean by "speed difference"? When you find an alignment, the relative speeds won't be constant throughout the entire alignment, so it's not clear what you're looking for. 2. What research/self-study have you done? DTW is well-documented in many resources. What approaches have you considered? What are you finding confusing? Once you understand DTW it seems like it's straightforward to answer your question, so I don't understand what you're uncertain about. Can you edit the question to clarify these points?
– D.W.
Jul 21, 2016 at 7:11

There is no single "speed difference". The way DTW works is that it checks whether you can find a match by slowing up and/or speeding up one of the signals.

For instance, suppose you want to match signal X to signal Y, which last 3 minutes. It's possible that the best match might involve speeding up signal Y for the first minute, slowing it down for the second minute, and leaving its speed unchanged for the third minute. Thus, there's no one speed, no one speed difference, and no simple answer to whether Y is faster than X or not. Rather, the answer is: "faster in parts, slower in others".

Once you find the best match using DTW, you can easily recover in which parts Y was faster than X, and in which parts Y was slower than X. I encourage you to do a bit more reading about how DTW works -- it'll probably all become clear as you understand the gist of the idea.

DTW is designed to handling local changes in timing. Global changes is time are referred to as Uniform Scaling [a].

You can create a FOR loop, loop over all possible Uniform Scalings, and record the one that has the lowest distance (under either euclidean distance, or DTW, or both [b])

That degree of Uniform Scaling is then your prediction of the speed relative to the oracle.

I have done this for guestures, speech, music etc.

Note that the range of all possible Uniform Scalings, should be limited, maybe something like 70 to 200%.

Eamonn