TOPICS
Search

Cosine Similarity


The cosine similarity of two nonzero real vectors x and y is the cosine of the angle between them,

 sim(x,y)=(x·y)/(||x||||y||).

It is invariant under positive rescaling of either vector. Its value lies in [-1,1], and for vectors with nonnegative components it lies in [0,1]. The quantity 1-sim(x,y) is often called cosine distance, although it does not in general satisfy the triangle inequality.


See also

Angle, Dot Product, Euclidean Norm, Triangle Inequality, Vector

Explore with Wolfram|Alpha

References

Salton, G. and McGill, M. J. Introduction to Modern Information Retrieval. New York: McGraw-Hill, 1983.

Cite this as:

Weisstein, Eric W. "Cosine Similarity." From MathWorld--A Wolfram Resource. https://mathworld.wolfram.com/CosineSimilarity.html

Subject classifications