The Euclidean distance (L2 distance) between two equal-length vectors x, y is:
d(x,y)=i∑(xi−yi)2Input: x = [3,4], y = [0,0]
Output: 5.0
√((3-0)² + (4-0)²) = √(9 + 16) = √25 = 5
Input: x = [1,2,3], y = [4,5,6]
Output: 5.196152422706632
√((1-4)² + (2-5)² + (3-6)²) = √(9 + 9 + 9) = √27 ≈ 5.196
Input: x = [0,0,0], y = [0,0,0]
Output: 0.0
Convert inputs to NumPy arrays and then compute
Sign in to take notes on this problem
Accepts: array
Accepts: array
The Euclidean distance (L2 distance) between two equal-length vectors x, y is:
d(x,y)=i∑(xi−yi)2Input: x = [3,4], y = [0,0]
Output: 5.0
√((3-0)² + (4-0)²) = √(9 + 16) = √25 = 5
Input: x = [1,2,3], y = [4,5,6]
Output: 5.196152422706632
√((1-4)² + (2-5)² + (3-6)²) = √(9 + 9 + 9) = √27 ≈ 5.196
Input: x = [0,0,0], y = [0,0,0]
Output: 0.0
Convert inputs to NumPy arrays and then compute
Sign in to take notes on this problem
Accepts: array
Accepts: array