In: Physics
Euclidian distance is defined as
d(p,q)=∑ni=1(pi−qi)^2. where pp and qq are vectors of n dimensions. Write a command to find the euclidian distance between "Mazda RX4" and "Mazda RX4 Wag"
We can calculate Euclidian distance in Python as follows.
from scipy.spatial import distance
mazdarx4=(21.0,6,160.0,110,3.90,2.620,16.46,0,1,4,4)
mazdarx4wag=(21.0,6,160.0,110,3.90,2.875,17.02,0,1,4,4)
d = distance.euclidean(mazdarx4, mazdarx4wag)
print("Euclidean distance: ",d)
Python in IDLE
Output