Euclidean Distance


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. def euclidean(x,y):
  2. sumSq=0.0
  3.  
  4. #add up the squared differences
  5. for i in range(len(x)):
  6. sumSq+=(x[i]-y[i])**2
  7.  
  8. #take the square root of the result
  9. return (sumSq**0.5)

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.