numpy euclidean distance code example
Example 1: distance euc of two arrays python
import numpy as np
a = np.array([1.0, 3.5, -6.3])
b = np.array([4.5, 1.6, 1.2])
dist = np.linalg.norm(a-b)
Example 2: euclidean distance python
from math import sqrt
pointA = (x, y)
pointB = (x, y)
distance = calc_distance(pointA, pointB)
def calc_distance(p1, p2):
return sqrt((p1[0]-p2[0])**2+(p1[1]-p2[1])**2)
Example 3: np euclidean distance python
import numpy as np
a = np.array((1,1,1))
b = np.array((2,2,2))
dist = np.linalg.norm(a-b)
Example 4: numpy euclidean distance
dist = numpy.linalg.norm(a-b)