nickgillian / grt

gesture recognition toolkit
861 stars 284 forks source link

Fixed class likelihood computation in DTW to avoid division by 0 #45

Closed terziman closed 8 years ago

terziman commented 8 years ago

In case when the tested data is the same as one of the templates selected by DTW (either because of low resolution input data or too much smoothing), the computed distance is 0 and the class likelihood is therefore undefined.

A solution could have been to manually detect 0 distances to force likelihood to 1 and 0 for other classes, but I think this solution is more generic and robust. If more than one computed distance is 0 (should never happen normally), the class likelihood will still be computed correctly.

I set the min possible distance threshold to 1e-9 arbitrarily based on the accuracy of double precision variables. I'm not sure it's the best possible value but it's working fine for me.

ngillian-google commented 8 years ago

Good catch!