I have 3 huge numpy arrays, and i want to build a function that computes the euclidean distance pairwise from the points of one array to the points of the second and third array.
For the sake of simplicity suppose i have these 3 arrays:
a = np.array([[1.64,0.001,1.56,0.1],
[1.656,1.21,0.32,0.0001],
[1.0002,0.0003,1.111,0.0003],
[0.223,0.6665,1.2221,1.659]])
b = np.array([[1.64,0.001,1.56,0.1],
[1.656,1.21,0.32,0.0001],
[1.0002,0.0003,1.111,0.0003],
[0.223,0.6665,1.2221,1.659]])
c = np.array([[1.64,0.001,1.56,0.1],
[1.656,1.21,0.32,0.0001],
[1.0002,0.0003,1.111,0.0003],
[0.223,0.6665,1.2221,1.659]])
I have tried this:
def correlation(x, y, t):
from math import sqrt
for a,b, in zip(x,y,t):
distance = sqrt((x[a]-x[b])**2 + (y[a]-y[b])**2 + (t[a]-t[b])**2 )
return distance
But this code throws an error: ValueError: too many values to unpack (expected 2)
How can i correctly implement this function using numpy or base python?
Thanks in advance