Statistics Glossary → Mahalanobis distance
Mahalanobis distanceconcept
A distance that measures how far an observation lies from the centre of a multivariate distribution, taking into account the scales of the variables and the correlations between them.
It is computed as D² = (x − μ)ᵀ S⁻¹ (x − μ), where μ is the mean vector and S the covariance matrix. Unlike the Euclidean distance, it downweights deviations on high-variance variables and does not penalise the 'expected' joint deviations of correlated variables. A combination of values that looks ordinary on each variable but is unusual jointly gives a large D². Under multivariate normality D² follows a chi-square distribution with p degrees of freedom, so the threshold D² > χ²(p; 1 − α) is used for outliers.
The mean and covariance are themselves affected by outliers. A few extreme observations can pull the centre toward themselves and inflate the covariance, hiding themselves (the masking effect). To reduce this, a robust Mahalanobis distance computed with a robust estimator such as the MCD is used. When the number of variables approaches the number of observations, S becomes unstable. In regression, the Mahalanobis distance in predictor space is directly related to leverage (hat values), and discriminant analysis assigns observations to the nearest group centre by this distance.
An everyday example
In a clothing company's customer data, both a height of 160 cm and a weight of 90 kg are ordinary on their own. But height and weight are strongly correlated, so someone of that height weighing 90 kg departs clearly from the overall pattern. The Euclidean distance finds this person unremarkable, whereas the Mahalanobis distance flags them as unusual, which may point to a data-entry error.
In MerQur
In anomaly detection, the 'Method' option offers Mahalanobis D² and robust Mahalanobis (MCD), and the 'Mahalanobis/MCD threshold (α)' flags outliers by the rule D² > χ²(p; 1 - α). In MANOVA, the 'Additional diagnostics' give the Mahalanobis distances of the residuals. In multiple linear regression, 'Extra output: Influence diagnostics' includes the Mahalanobis distance, and in discriminant analysis kNN classification can use Mahalanobis (pooled covariance) as its 'Distance metric'.
Analyses where this concept appears
MANOVAMultiple Linear RegressionDiscriminant Analysis (LDA / QDA)Anomaly Detection
Related concepts
Distance measure (Euclidean, Manhattan, Gower, great-circle)OutlierMinimum covariance determinant (MCD) and robust distance