Reputation: 1305
I am trying to use the cosine distance in pdist2
. I am confused about it's output. As far as I know it should be between 0 and 1. Since MATLAB uses 1-(cosine), then 1 would be the highest variability while 0 would be the lowest. However the output seems to range from 0.5 to 1.5 or something along that!
Can somebody please advise me on how to interpret this output?
Upvotes: 2
Views: 2949
Reputation: 112669
From help pdist2
:
'cosine' - One minus the cosine of the included angle between observations (treated as vectors)
Since the cosine varies between -1 and 1, the result of pdist2(...'cosine')
varies between 0 and 2. If you want the cosine, use 1-pdist2(matrix1,matrix2,'cosine')
.
Upvotes: 5