Possible miscalc in OptimalCosineDistance#4

Closed
opened this Issue Feb 3, 2013 · 0 comments

1 participant

Owner
commented Feb 3, 2013

I am writing to you since we found a typo in the OptimalCosineDistance function. There is a minus instead of a plus sign (in the commented line):

```float OptimalCosineDistance(FloatArrayContainer v1, FloatArrayContainer v2) {
float a = 0.0;
float b = 0.0;
float angle;
float score;

int mincount = (v1.itemCount < v2.itemCount ? v1.itemCount : v2.itemCount);

for (int ii = 0; ii < mincount; ii+=2) {
a += v1.items[ii] * v2.items[ii] + v1.items[ii+1] * v2.items[ii+1];
//      b += v1.items[ii] * v2.items[ii+1] + v1.items[ii+1] * v2.items[ii];
b += v1.items[ii] * v2.items[ii+1] - v1.items[ii+1] * v2.items[ii];
}

angle = atanf( b / a );
score = acosf(a * cos(angle) + b * sin(angle));

return score;
}```

This made the predictions far more accurate. Thought I'd let you know =)

was assigned Feb 3, 2013
added a commit that closed this issue Feb 3, 2013
 britg `Fix bug in OptimalCosineDistance, fixes #4` `00f0ba3`
closed this in `00f0ba3` Feb 3, 2013