Difference between scipy pairwise distance and X.X+Y.Y - X.Y^t

柔情痞子 提交于 2019-12-02 06:52:05

pdist(..., metric='seuclidean') computes the standardized Euclidean distance, not the squared Euclidean distance (which is what cal_pdist returns).

From the docs:

Y = pdist(X, 'seuclidean', V=None)

Computes the standardized Euclidean distance. The standardized Euclidean distance between two n-vectors u and v is

   __________________
  √∑(ui−vi)^2 / V[xi]

V is the variance vector; V[i] is the variance computed over all the i’th components of the points. If not passed, it is automatically computed.

Try passing metric='sqeuclidean', and you will see that both functions return the same result to within rounding error.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!