CosineDistance

Cosine similarity (WMA)


CosineDistance[u, v]

returns the angular cosine distance between vectors u and v.

The cosine distance is equivalent to $1 - (u.Conjugate[v]) / (Norm[u] Norm[v])$.

When the length of either vector is 0, the result is 0:

The order of the vectors influences the result:

Cosine distance includes a dot product scaled by norms:

A Cosine distance applied to complex numbers, uses Abs[] for Norm[] and complex multiplication for dot product,
1 - u * Conjugate[v] / (Abs[u] Abs[v]):

ChessboardDistance
EuclideanDistance