lsingal / fastdtw

Automatically exported from code.google.com/p/fastdtw

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Euclidean distance incorrectly equals Manhattan distance

GoogleCodeExporter opened this issue · comments

What steps will reproduce the problem?
1. Follow readme.txt and run the example FastDtwTest with Euclidean and 
Manhattan distances
2. Warping distances are identical
3. Try different data sets

What is the expected output? What do you see instead?

I expect the 2 distances to be different.

What version of the product are you using? On what operating system?

1.1.0

Please provide any additional information below.

The error appears to be in com.util package and the ManhattanDistance and 
EuclideanDistance classes. Although the formulas are correct the 2 methods are 
invoked for vectors containing single points, hence the inner loops are 
computing the absolute difference (Manhattan distance) because the comparison 
is always between 2 points. 

Original issue reported on code.google.com by gste...@gmail.com on 14 Jul 2014 at 8:24

To make this more clear:

Essentially the Euclidean distance outputs sqrt((x1-x2)^2) and is calculated 
for every pair pf points. For any given pair, sqrt((x1-x2)^2) = abs(x1-x2).
So the warping distance which is the sum of all distances along the minimum 
distance path is: sum(sqrt((x1-x2)^2)) = sum(abs(x1-x2)). 
The Euclidean distance formula should instead output the squares, i.e. 
(x1-x2)^2 and the warping distance should be:
sqrt(sum((x1-x2)^2)) != sum(abs(x1-x2))

Original comment by gste...@gmail.com on 14 Jul 2014 at 8:46