We are now in the PCA journey, station 2.
Like the picture above, we want to know the difference between x and y. There are two ways for us to inspect, distance between x and y, and the angle between x and y. When it comes to the distance, the formula is as below:
We firstly make x - y, and then have the transpose of (x-y) time (x-y), and then have it be a root square value.
import numpy as np
x = np.array([1, 2])
y = np.array([2, 1])
def distance(x, y):
distance = ((x-y)@(x-y))**0.5
return distance
distance(x, y)