Mahalanobis Distance

Calculating distances, or similarities, between datasets is one of the key techniques deployed in any machine learning algorithm for Artificial Intelligence (AI). One of the key distance measures is the Mahalanobis distance which not only calculates the distance between a vector and a matrix, but successfully eliminates potential correlations between the variables representing the matrix.

This tutorial eliminates any “mystery” associated with this measure and shows how simple it is to calculate it in Excel. In addition, the Excel file contains the VBA code, so if you do not want to use standard Excel functions, you can run the code.

Although it is easy to calculate the Mahalanobis distance, understanding why and how it works is a bit more complex. However, we took the complexity out of the main body of the tutorial and placed it in a series of appendices.

The tutorial on Mahalanobis distance can be found here, and the spreadsheet with all the calculations and the VBA macros is placed here.