Package elki.distance

Class SqrtCosineDistance

  • All Implemented Interfaces:
    Distance<NumberVector>, NumberVectorDistance<NumberVector>, PrimitiveDistance<NumberVector>, SpatialPrimitiveDistance<NumberVector>

    public class SqrtCosineDistance
    extends CosineDistance
    Cosine distance function for feature vectors using the square root.

    The cosine distance is computed from the cosine similarity by sqrt(1-cosine similarity).

    Cosine similarity is defined as \[ \tfrac{\vec{x}\cdot\vec{y}}{||a||\cdot||b||} \] This versions of cosine distance then is defined as \[ \sqrt{2 - 2\tfrac{\vec{x}\cdot\vec{y}}{||a||\cdot||b||}} \in [0;2] \]

    Because of the square root, this is more expensive than regular cosine, but because this corresponds to Euclidean distance on normalized vectors, it is a metric on normalized vectors.

    Since:
    0.1
    Author:
    Erich Schubert