EDIT (No duplicate of Converting similarity matrix to (euclidean) distance matrix): This question is centered on asking how to combine values from Euclidean and Cosine distances obtained from not-normalized vectors. Being not normalized the distances are not equivalent, as clarified by @ttnphns in comments below. Also I have cosine distance (1- similarity), not cosine similarity.

Short question: How can I combine Euclidean and Cosine/Angular distances between multivariate vectors successfully? Are there special considerations regarding to the objective of the comparison? (for example: to take more into consideration magnitude over orientation)


I'm using Dynamic Time Warping (DTW) for matching short time series and building a similarity matrix, with the intention of clustering the different time series and get insights from the clusters.

I'm using physical performance features of athletes, but instead of using the overall magnitude of each measure, I use the number of standard deviations that an athlete from the group mean. So the time series (multivariate) is conformed by successive points indicating the deviation from the mean an athlete has over time.

My main objective is to cluster together windowed-sections of the time series that reflect remarkable similar behavior in the up-and-down of values.

So, for DTW I need a distance measure to be used to find the warping path, and then compute the overall distance between pairwise time series. I will like to take into account both the magnitude of the vectors (each point in the time series) and the orientation. It seems then that Euclidean distance can work well for the first one and Cosine/Angular distance for the second one.

How can I combine both distances in order to keep their properties?

  • 2
    $\begingroup$ Cosine is directly convertible into euclidean distance stats.stackexchange.com/a/36158/3277. $\endgroup$
    – ttnphns
    Apr 1, 2016 at 12:33
  • $\begingroup$ Thanks for your answer @ttnphns I can see in the link that cosine is convertible but what does this means? Does this imply that I should convert it to the euclidean space and average with the calculated euclidean distance, for instance? Or that I can use just one of the two distances (euclidean or cosine) and the effect will be similar (which I understand is not true). I don't need exactly to convert it to euclidean distance for any reason, but I do want to take advantage of the information provided by both distances (if this makes sense) $\endgroup$
    – Javierfdr
    Apr 1, 2016 at 12:45
  • $\begingroup$ Both provide the same information. You can see on the picture in the link that if both $h$s are unit length cosine and eucl d are equivalent, only one being in angular and the other being in linear form. So, if you have computed your eucl distances between your data vectors based on those vectors standardized (st.dev.=$h$=1) then the distances are directly comparable with cosines; so you may convert the cosines into eucl. distances, too, and unite it all in one distance matrix. You can also convert the distances into cosines, if you prefer cosine for further data analysis. $\endgroup$
    – ttnphns
    Apr 1, 2016 at 12:57
  • $\begingroup$ Ok I see what you say. I have standarized the columns/features of my dataset so they have std.dev = 1, however the length of the vector is not normalized by its norm. Given that Euclidean distance between vector will provide different information than Cosine; since the lack of normalization, right? @ttnphns $\endgroup$
    – Javierfdr
    Apr 1, 2016 at 13:12
  • $\begingroup$ If you had been standardising features (columns) but then you computed euclidean distances between cases (rows) - then no, $h$s are not unit length and so you cannot see it as direct equivalent to cosine. It then corresponds to the scalar product. $\endgroup$
    – ttnphns
    Apr 1, 2016 at 13:19


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.