CalcWorldHub
Free online calculator · no signup

Two dimensional Mahalanobis distance calculator

Measure a two-feature point’s distance from a reference mean using its covariance geometry.

4,000 tools
Two dimensional Mahalanobis distance calculator — First coordinate offset from mean, Second coordinate offset from mean, First variance and calculation method
Two dimensional Mahalanobis distance calculator: inputs and calculation method.

How to use this calculator

Measure a two-feature point’s distance from a reference mean using its covariance geometry.

  1. Enter First coordinate offset from mean, Second coordinate offset from mean, First variance, Second variance, then complete the remaining labeled fields. Match the units shown beside each field and review the result together with the assumptions below.
  2. Read the worked example below to check the expected input format and result.
  3. Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
Calculation guide

Two dimensional Mahalanobis distance explained

Mahalanobis distance measures a coordinate offset in the scale and correlation structure of a covariance matrix. The two-variable form uses both variances and their covariance, so equal geometric distances can have different standardized distances along different directions.

Inputs, symbols, and units

x — First coordinate offset from mean
First coordinate minus its reference mean, in the first variable’s unit.
y — Second coordinate offset from mean
Second coordinate minus its reference mean, in the second variable’s unit.
a — First variance
Positive first-variable variance, in the square of that variable’s unit.
b — Second variance
Positive second-variable variance, in the square of that variable’s unit.
c — Covariance
Cross covariance in the product of the two variable units; require a×b−c² > 0.

Formula and method

sqrt((b*x*x-2*c*x*y+a*y*y)/(a*b-c*c))

Covariance matrix must be positive definite; this alone is not an outlier probability or a distribution test..

A worked scenario

First coordinate offset from mean = 2; Second coordinate offset from mean = 1; First variance = 4; Second variance = 1; Covariance = 0.5.

  • Mahalanobis distance: 1.26491106

The covariance determinant is 4×1−0.5²=3.75. The inverse-covariance quadratic form is (1×2²−2×0.5×2×1+4×1²)/3.75=1.6, so distance is √1.6≈1.264911. This is a distance, not an outlier probability.

Assumptions and edge cases

Covariance matrix must be positive definite; this alone is not an outlier probability or a distribution test.

Frequently asked questions

Are offsets raw coordinates?

Subtract the reference mean first.

Why include covariance?

Correlated directions have different expected variation.

What if the matrix is singular?

The inverse distance is undefined and rejected.

How do I use the Two dimensional Mahalanobis distance calculator?

Enter First coordinate offset from mean, Second coordinate offset from mean, First variance, Second variance, then complete the remaining labeled fields. Match the units shown beside each field and review the result together with the assumptions below.

What is a worked example of Two dimensional Mahalanobis distance?

First coordinate offset from mean = 2; Second coordinate offset from mean = 1; First variance = 4; Second variance = 1; Covariance = 0.5. Mahalanobis distance: 1.26491106 The covariance determinant is 4×1−0.5²=3.75. The inverse-covariance quadratic form is (1×2²−2×0.5×2×1+4×1²)/3.75=1.6, so distance is √1.6≈1.264911. This is a distance, not an outlier probability.