I don't understand this picture, which says if we change the coordinate system, we would have the same result for $L_2$ distance, whereas, our result would differ for $L_1$ distance. What does it mean by coordinate system? $(0,0)$ if yes, the assertion is not true.


I mean, suppose we have a picture with this matrix A, and another with B, for calculating their L1(Manhattan) and L2(Euclidean) distances, we would have the following code, how is this slide applied to the proposed problem?

import numpy as np
A = [[0,21,2],[3,4,5],[6,7,8]]
B = [[5,6,37],[8,0,10],[11,12,13]]
L1 = np.zeros((3,3))
L2 = np.zeros((3,3))
C = np.zeros((3,3))
for i in range(len(A)):
    for j in range(len(A)):
        L1[i][j] = np.abs(A[i][j] - B[i][j])
        L2[i][j] = np.power((A[i][j] - B[i][j]),2)    

For example, consider the green line. What is its length? In $L_2$, the answer is $1$, in $L_1$, the answer is $1$ as well.

Now, for the same line, let's rotate it $45^\circ$ counterclockwise. What is the length again? In $L_2$, its length remains to be $1$. However, in $L_1$, using Manhattan distance, it's length is now $\frac{1}{\sqrt{2}}+\frac{1}{\sqrt{2}}=\sqrt2$. As we can see, rotation can change $L_1$ distance.

Rather than rotating the line, we could also equivalently rotated our $x$ and $y$-axis instead.

enter image description here

  • $\begingroup$ Thank you so much. Your explanation was very clear. $\endgroup$ – Fatemeh Asgarinejad May 26 at 4:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.