Euclidean Distance Improvement

When I first wrote the Euclidean Macro Program, I create a .py file which contained the euclidean equation. I originally simply did it for 3 dimensions but made it more universal by allowing it to accept to vectors of any size. The euclidean equation for that is simply:

dn=(x1y1)2+(x2y2)2...(xnyn)2 d_n=

The new function takes the difference between the two and squares it depending on the length of the vector. This isn’t full proof in that they two vectors should be of equal size.

def euclidean_dist(x,y):
    for i in range(len(x)):
        val = (x[i]-y[i])**2
        val += val
    return sqrt(val


Date
September 25, 2018