What is the difference between Hamming Distance and Manhattan Distance for non-binary data (specifically I am comparing points in $\mathbb{R}^2$)? I understand Manhattan sums the absolute difference in the and x and y directions but doesnt hammming distance do the same thing?
1 Answer
The Hamming distance between two length-$n$ vectors is the number of coordinates in which they differ. I've only ever seen it on finite alphabets, i.e. vectors in $\Sigma^n$ where $|\Sigma|\in \mathbb{N}$. In theory there is no problem with extending this to $\mathbb{R}$, but you may have to be careful with how you use equality of floats for instance.
Specifically over $\mathbb{R}^2$, if we consider $x=(x_0,x_1)$ and $y=(y_0,y_1)$: $$\begin{cases} dist_\textsf{Manhattan}(x,y)=|x_0-y_0|+|x_1-y_1|\\ dist_\textsf{Hamming}(x,y)=\delta_{x_0,y_0}+\delta_{x_1,y_1}\end{cases}$$
Where $\delta_{a,b}=\begin{cases}1 \text{ if }a\neq b \\0 \text{ otherwise}\end{cases}.$
The two coincide in $\{0,1\}^n$, because in that case we have $\delta_{a,b}=|a-b|$.