计算矩阵A与矩阵B的欧式距离
1. 从向量的欧式距离谈起
向量x为1x3的行向量,向量y为1x3的行向量,求向量x与向量y的欧式距离
x = ( a 11 a 12 a 13 ) x = \begin{pmatrix}a_{11} & a_{12} & a_{13}\\\end{pmatrix} x=(a11a12a13)
y = ( b 11 b 12 b 13 ) y = \begin{pmatrix}b_{11} & b_{12} & b_{13}\\\end{pmatrix} y=(b11b12b13)
d i s t x , y = ( a 11 − b 11 ) 2 + ( a 12 − b 12 ) 2 + ( a 13 − b 13 ) 2 dist_{x,y}=\sqrt{(a_{11} - b_{11})^2 + (a_{12} - b_{12})^2 + (a_{13} - b_{13})^2} distx,y=(a11−b11)2+(a12−b12)2+(a13−b13)2
变形为:
d i s t x , y = a 11 2 + a 12 2 + a 13 2 + b 11 2 + b 12 2 + b 13 2 − 2 a 11 b 11 − 2 a 12 b 12 − 2 a 13 b 13 dist_{x,y}=\sqrt{a_{11}^2 + a_{12}^2 + a_{13}^2 + b_{11}^2 + b_{12}^2 + b_{13}^2 - 2a_{11}b_{11} - 2a_{12}b_{12} - 2a_{13}b_{13} } distx,y=a112+a122+a132+b112+b122+b132−2a11b11−2a12b12−2a13b13