Skip to content
Omnikalc

Mahalanobis distance calculator: how unusual is this point, given the correlation?

Enter a point, the means, the standard deviations and the correlation of two variables to get the Mahalanobis distance and the share of points farther away.

Updated on
Your inputs

Value out of range

Value out of range

Value out of range

Value out of range

Value out of range

Value out of range

Value out of range

Results

Mahalanobis distance

2.107

Inside the 95 % ellipse: a typical point
Squared Mahalanobis distance
4.438
Standardised distance ignoring the correlation
2.567
Share of the population farther from the centre
10.9 %
Plain distance in the original units
29.15

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.

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.

Frequently asked questions

What is the Mahalanobis distance?

It is a distance from a point to the centre of a group that takes into account the spread of each variable and their correlation. It is measured in standard deviations along the direction of the point, so a value of 3 means the point is as far from the centre as a 3-sigma outlier in one variable.

How is it different from the Euclidean distance?

The Euclidean distance treats all directions alike and ignores scale. If one variable is in kilograms and another in metres, the Euclidean distance mostly reflects the one with bigger numbers. The Mahalanobis distance rescales each variable and tilts the axes to match the correlation, so the surfaces of equal distance are ellipses, not circles.

How do I use it to find outliers?

For two variables that are roughly normal, the squared distance follows a chi-square distribution with two degrees of freedom. A distance above 2.448 puts the point outside the 95 percent ellipse, and above 3.035 outside the 99 percent one. With more variables, the cut-offs are larger, since there are more dimensions.

Why does the correlation matter?

A positive correlation makes points along the main diagonal ordinary and points off it unusual. A student with a high maths score and a low physics score would be farther from the centre than the same two numbers with matching scores, even when the plain distance is the same. The calculator shows how much the correlation changes the answer.

Was this calculator helpful?

Thanks for your feedback!

Results are estimates provided for information purposes. They do not replace professional advice.