[SciPy-User] It was quite confusing to use scipy.spatial.distance.cdist

江大伟 zw4131 at gmail.com
Sun May 29 12:15:32 EDT 2011


I want to computes euclidean distance between a vector and 2 vector. For
example:

A=numpy.array([0,0])

B= numpy.array([[1,0],[0,1]])

I want to computes euclidean distance between vector A and each vector in
matrix B.

My expected result is the vector [1,1]



So I use scipy.spatial.distance.cdist(A, B ,'euclidean')

But the error said A must be a 2-dimensional array.

So I turned to use scipy.spatial.distance.euclidean(A,B), it worked, but the
result was a value 1.4142.

It was quite confusing!!



So I suggest adopting an uniform function to Computes the distance between
any-dimensional array. Scipy.spatial.distance.cdist() is a very good
function, but it can be extended to Computes the distance between a vector
and a vector as well as between a vector and n vectors. That would be
perfect !!.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20110530/f4e61fc8/attachment.html>


More information about the SciPy-User mailing list