The cosine similarity of two vectors: from -1 (opposite) through 0 (unrelated) to 1 (the same direction). Computed in double and kept within -1..1 against rounding.
The cosine similarity of two vectors: from -1 (opposite) through 0 (unrelated) to 1 (the same direction). Computed in double and kept within -1..1 against rounding.
A zero vector has no direction, so its similarity to any vector - another zero vector included - is 0; so is that of two empty arrays. A NaN or infinite component gives NaN unless the other vector is zero.
Attributes
Throws
IllegalArgumentException
when the vectors differ in length, as vectors from two different models may