# What is Mahalanobis distance, & how is it used in pattern recognition?

Can someone explain to me the concept of Mahalanobis distance? For example, what is the Mahalanobis distance between two points x and y, and especially, how is it interpreted for pattern recognition?

## 2 Answers

Mahalanobis distance provides a way to measure how similar some set of conditions is to a known set of conditions. It accounts the covariance among variables.

It is calculated as: $$D^2=(\bf x-m)^TC^{-1}(x-m)$$ where: \begin{align} D^2 &= \text{Mahalanobis distance} \\ {\bf x} &= \text{Vector of data} \\ {\bf m} &= \text{Vector of mean values of independent variables} \\ {\bf C^{-1}} &= \text{Inverse Covariance matrix of independent variables} \\ {\bf T} &= \text{Indicates vector should be transposed} \\ \end{align}

This page provides a detailed explanation (with examples from landscape analysis).

• thanks , the source gave me a good explanation for a start – ayariga Oct 26 '12 at 2:25

Mahalanobis distance is used to find outliers in a set of data. I don't know what field you are in, but in psychology it is used to identify cases that do not "fit" in with what is expected given the norms for the data set. For example, if your sample is composed of individuals with low levels of depression and you have one or two individuals with very high levels of depression, then they would have Mahalanobis distances which are greater than the expected critical value. You would probably want to remove these cases if they are very extreme AND if you feel that they do not fit in with your data set. (Using provided example, your sample is composed of individuals with low levels of depression, therefore those one or two individuals with high levels of depression do not fit in with the rest). Identifying outliers is very important because many statistical analyses have an "assumption of normality" i.e. an expectation that your data a normally distributed. Outliers can also contribute to skewed data, and for this reason they should also be removed. (Unless you transform the entire variable and this corrects the skew). Many stats programs such as SPSS allow you to calculate the M distances and the probability associated with each score to identify outliers. I can provide you with SPSS instructions, but I don't know if you are using SPSS.

## protected by kjetil b halvorsenNov 3 '17 at 19:03

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?