点(1,1)和点(2,2)的余弦距离,汉明距离、欧氏距离、曼哈顿距离分别是多少
点$(1,1)$和点$(2,2)$的坐标分别为$(1,1)$和$(2,2)$.
余弦距离:
$\cos \theta=\frac{(1,1)\cdot(2,2)-1\times1-1\times2}{\sqrt{1^2+1^2}\times\sqrt{2^2+2^2}}=-\frac{3}{5\sqrt{2}}$,
所以余弦距离为$\sqrt{(1-\frac{3}{5})^2+(1-\frac{3}{5})^2}=\frac{\sqrt{8}}{5}$.
汉明距离:
在两个向量中,不同位置的元素采用不同的符号表示,因此可以按照如下方式计算汉明距离:
$\cos \theta=(1,1)\cdot(2,2)=1$,
所以汉明距离为0.
欧氏距离:
$\cos \theta=\frac{(1,1)\cdot(2,2)-1\times1-1\times2}{\sqrt{1^2+1^2}\times\sqrt{2^2+2^2}}=-\frac{3}{5\sqrt{2}}$,
所以欧氏距离为$\sqrt{(1-\frac{3}{5})^2+(1-\frac{3}{5})^2}=\frac{\sqrt{8}}{5}$.
曼哈顿距离:
在两个向量中,相同位置的元素取相同的符号,不同位置的元素取相反的符号。因此可以按照如下方式计算曼哈顿距离:
$\cos \theta=(1,1)\cdot(2,2)=1$,
所以曼哈顿距离为0.
免责声明:
以上内容除特别注明外均来源于网友提问,创作工场回答,未经许可,严谨转载。