Mahalanobis Distance

Let $\mathbf x$ be a vector, and assume we have a distribution with mean $\mathbf \mu$ and covariance matrix $S$. The Mahalanobis distance with respect to the distribution is defined as

$$D(\mathbf x) = \sqrt{(\mathbf x – \mathbf \mu)^TS^{-1}(\mathbf x – \mathbf \mu)}.$$

Why? Well, $S$ is positive-definite, so we can decompose $\mathbf x – \mu$ into $\sum a_i\mathbf e_i$, where $\mathbf e_i$ are the orthonormal eigenvectors of $S$ (with corresponding eigenvalues $\lambda_i$). Then $S^{-1} a_i \mathbf e_i = \frac{a_i \mathbf e_i}{\lambda_i}$ and so

$$D(\mathbf x) = \sqrt{\sum \frac{a_i^2}{\lambda_i}}.$$

So the Mahalanobis distance takes into account how far out from the mean we are, where the meaning of “far out” depends on the direction you’ve traveled from the mean.

This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.