8

I am trying to find the similarity between two time series, but not in terms of distance, in something more sensible such as percentage of similarity. In other words I need something that shows the similarity, not dis-similarity.

The dynamic time warping gives a very good response, when trying to compare the time-series. But the distance computed by dynamic time warping depends on the duration of the time series and the magnitude of the template and the query. Moreover, it shows the distance, which demonstrates the dis-similarity.

Is there a way to convert the distance from DTW into some form of normalized similarity measure?

D.W.
  • 167,959
  • 22
  • 232
  • 500
aghd
  • 183
  • 1
  • 4

1 Answers1

11

Sure. There's a straightforward way to convert an unnormalized distance metric into a normalized similarity measure. Basically, use

$$S(x,y) = \frac{M - D(x,y)}{M},$$

where $D(x,y)$ is the distance between $x$ and $y$, $S$ is the normalized similarity measure between $x$ and $y$, and $M$ is the maximum value that $D(x,y)$ could be.

In the case of dynamic time warping, given a template $x$, one can compute the maximum possible value of $D(x,y)$. This will depend on the template, so $M$ becomes $M(x)$, and the formula becomes

$$S(x,y) = \frac{M(x) - D(x,y)}{M(x)}.$$

So how do you compute $M(x)$? Basically, multiply the length of the template (the number of samples in the time series), times the maximum value of each sample. If each sample is in the range $[0,1]$, then the maximum value of each sample is 1, so $M(x)$ becomes just the length of $x$. This gives a simple upper bound on $D(x,y)$. [Trivia: in fact one could compute a slightly tighter upper bound, but in practice that's probably not necessary.]

It is easy to verify that the similarity measure is always in the range $[0,1]$ and thus is normalized as you were hoping for.

D.W.
  • 167,959
  • 22
  • 232
  • 500