Change the formula of dtw_std

35 views
Skip to first unread message

Seyed Hossein Chavoshi

unread,
Jan 15, 2013, 9:10:45 AM1/15/13
to mlpy-g...@googlegroups.com
Dear All,

I am very new in python programming and I am trying to use the DTW package inside the mlpy in my research. To do so, I need to change the formula of  Euclidean distance in dist_only to another function. Since I am working with the angular sequences the normal Euclidean distance does not work for me. Instead I want to change that function to dist=(1-cos(x-y))/2.

Could you please help me in this issue? I do not even know where I can find that defined function.

I am looking forward to your clues.

With best regards
Hossein

 

Emil Kjer

unread,
Jan 16, 2013, 9:10:47 PM1/16/13
to mlpy-g...@googlegroups.com
If you are using the DTW package change euclidian distance equation in method "e_dist" in the file mlpy/dtw/cdtw.c:
// euclidean distance
double e_dist(double x, double y)
{
  return fabs(x - y);
}

to

// euclidean distance
double e_dist(double x, double y)
{
  return (1-cos(x-y))/2;
}

And rebuild the package. Haven't tested but it should work. However, the above is the easy solution and you should maybe consider adding an additional distance method used in the std method. 

Let me know if further assistance is needed.

/Emil Kjer
Reply all
Reply to author
Forward
0 new messages