Some points look far from the centre only because the variables are measured on different scales, and others look close while being strange given how the variables move together. The Mahalanobis distance calculator takes the point, the means, the standard deviations and the correlation of two variables, and gives the Mahalanobis distance, its square, the standardised distance without the correlation, the share of the population farther away and the plain distance.
How the calculation works
- Enter the point to test, as its values on two variables X and Y, for example a student’s scores in two exams.
- Enter the mean and the standard deviation of each variable in the group, and the correlation between them.
- Each deviation is first standardised: zx = (x − mean) ÷ sd. The squared distance is D² = (zx² − 2 × r × zx × zy + zy²) ÷ (1 − r²).
- A normal group has 95 percent of its points within D = 2.448 and 99 percent within D = 3.035. For two variables, the share farther away is e^(−D²/2).
Example
A student scores 85 in maths (mean 70, sd 10) and 90 in physics (mean 65, sd 12), and the two exams have a correlation of 0.6. The standardised deviations are 1.5 and 2.083. Ignoring the correlation, the distance would be 2.567. With the correlation, D² = (2.25 − 2 × 0.6 × 1.5 × 2.083 + 4.340) ÷ 0.64 = 4.438, so D = 2.107. About 10.9 % of students lie farther from the centre. The student is within the 95 percent ellipse, since a high maths score usually goes with a high physics score.
Why it matters
Outlier detection, quality control, fraud screening and classification all need a distance that respects the data. The Mahalanobis distance is the standard answer, and working it out for two variables shows exactly what it does before it is used on dozens of variables with software.
Good to know
The calculator is for two variables and assumes a bivariate normal distribution, which is what makes the thresholds exact. Real data may have heavy tails, and the mean and the covariance can themselves be pulled by outliers. For more variables, you need a covariance matrix and the cut-offs of the chi-square distribution with more degrees of freedom.
Related tools
The z-score calculator standardises one variable, the normal distribution calculator gives chances for one variable, the covariance calculator gives the link between two, and the Manhattan distance calculator measures a different kind of distance.