Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- # Example points in 3-dimensional space...
- x = (4, 5, 6)
- y = (7, 8, 9)
- # Given that x and y are both tuples in k-dimensional space, we
- # can calculate the Euclidean distance from x to y as follows...
- distance = math.sqrt(sum([(a - b) ** 2 for a, b in zip(x, y)]))
Add Comment
Please, Sign In to add comment