3

I know that the Angular Distance is a proper metric but I'm struggling to find a reference that states that and proves all the properties for that distance. In the book Mining of Massive Datasets (Page 95) the authors briefly argue that the properties hold for what they call "Cosine Distance", which is just the angle between two vectors. However, I've read that the Angular Distance must be normalised in order to be considered a metric.

  1. Does the Angular Distance have to be normalised for it to be a metric?
  2. Can you point me to a reference that proves that the Angular Distance is a proper metric?
Toni
  • 41
  • 2

1 Answers1

0

Metric

Let $X$ be an arbitrary set. A function $d: X \times X \rightarrow \mathbb{R}$ is called a metric on $X$, iff the following properties hold true for all $x, y, z \in X$:

  • identity of indiscernibles: $\forall x, y \in X: d(x, y) = 0 \Leftrightarrow x = y$
  • symmetry: $\forall x, y \in X: d(x, y) = d(y, x)$
  • triangle inequality: $\forall x, y, z \in X:d(x, z) \leq d(x,y) + d(y, z)$

Cosine Distance

Cosine distance is defined as:

$$d_{cos}(x, y) := 1 - \cos(\theta) = 1 - {\mathbf{A} \cdot \mathbf{B} \over \|\mathbf{A}\| \|\mathbf{B}\|} = 1 - \frac{ \sum\limits_{i=1}^{n}{A_i B_i} }{ \sqrt{\sum\limits_{i=1}^{n}{A_i^2}} \sqrt{\sum\limits_{i=1}^{n}{B_i^2}} }$$

Cosine distance is not a metric in $\mathbb{R}^n$, because the identity of indiscernibles does not hold true:

$$d(0.5, 1) = 1 - \cos(0°) = 1 - \frac{1}{1} = 0\text{, but } 0.5 \neq 1$$

To the question if cosine distance is a metric on $S_n = \{x \in \mathbb{R}^n: ||x|| = 1\}$:

\begin{align} x &= y\\ \Rightarrow d(x,y) &= d(x,x)\\ &= 1 - \sum_{i=1}^n x_i^2\\ &= 0 \end{align}

So that looks good.

We also know that $\cos(\theta) = 1 \Leftrightarrow \theta \in \{0°, 180°\}$. This means it still does not have the identity of indiscernibles attribute. We have to reduce the space to the non-negative unit sphere $S_n^+ = \{x \in \mathbb{R}^n: ||x|| = 1 \land x^{(i)} \geq 0\}$.

Martin Thoma
  • 9,821
  • 1
    The cosine distance is not even a distance for vectors of uni length because it violates the triangle inequality. Also, the question was not about the cosine distance but about the angular distance d_a(x,y) = \theta(x,y) which would also violate the identity of indiscernibles, but the triangle inequality should hold. – McLawrence Jul 18 '19 at 10:40
  • Can you show the triangle equation for the angular distance? Geometrically it is clear, but I am not able to formalize it. – McLawrence Jul 18 '19 at 11:04