Multidimensional Euclidean Distance in Python
Use either
numpy.sqrt(numpy.sum((A - B)**2))
or more simply
numpy.linalg.norm(A - B)
Perhaps scipy.spatial.distance.euclidean
?
Examples
>>> from scipy.spatial import distance >>> distance.euclidean([1, 0, 0], [0, 1, 0]) 1.4142135623730951 >>> distance.euclidean([1, 1, 0], [0, 1, 0]) 1.0