Mahalanobis Distance

In the following, we will visualize the Mahalanobis distance between two planes using a Python script.

We sample 20 points at random and organize them on two planes, centered at (0, 0.5, 0.5) and (1, 0.5, 0.5) respectively. We then rotate one of the two planes around z axis for 90 degrees, and see how the distance changes. Also, we set different noise levels on the normal direction of the planes, and see how the distance changes.

Before Rotation, Noise Level = 0.1, M-distance = 6-9

After Rotation, Noise Level = 0.1, M-distance = 2-4

Before Rotation, Noise Level = 0.001, M-distance = 600-900

After Rotation, Noise Level = 0.001, M-distance = 2-4

Furthermore, if we set noise level to 0.01, the results are still consistent. Figures omitted.

  • Before Rotation, Noise Level = 0.01, M-distance = 60-90

  • After Rotation, Noise Level = 0.01, M-distance = 2-4

If we rotate the plane slightly, such as even only 10 degrees, the distance will decrease drastically.

  • Before Rotation, Noise Level = 0.001, M-distance = 600-900

  • After Rotation, Noise Level = 0.001, M-distance = 20-40

Python Code

Last updated

Was this helpful?