The guide
A point can look ordinary on every variable and still sit far outside the cloud
Standard scores treat each variable alone. Mahalanobis distance adds the correlations, which is why a point with small z-scores can be a joint outlier.
- 3.5665 distance of (7, 5) from the ten-point cloud
- 1.9915 plain straight-line distance to the same point
- 0.0017 chance of a distance at least that large
- 6.7082 distance at z = 1.5 on both, correlation 0.9
- 2.4477 95 percent distance for two variables
Read the full guide Fold the guide
A standard score answers a narrow question. It tells you how many standard deviations a value sits from the mean of one variable, and the Wikipedia entry on standard scores defines it exactly that way: subtract the mean, divide by the standard deviation. Ask that question of each variable in turn and you can feel reassured when every answer is small.
The reassurance can be false. Two variables that rise and fall together form a long thin cloud, and a point can lie across the thin direction while staying inside the range of each variable alone. Every score looks ordinary. The point is still far from where the data live.
P. C. Mahalanobis introduced the distance that fixes this in 1936. The Wikipedia article on the distance describes it as a measure between a point and a probability distribution, a multivariate generalisation of the absolute standard score that takes the correlations of the data into account.
Small scores, large distance
Take ten round points, not measurements: (2, 3.1), (3, 3.9), (4, 5.2), (5, 5.8), (6, 7.1), (7, 7.8), (8, 9.3), (9, 9.9), (4.5, 3) and (6.5, 8). The mean is (5.50, 6.31). The sample variances are 4.8889 and 6.2321, and the covariance is 5.2056, so the two variables climb together.
Now test the point (7, 5). Its z-scores are 0.6784 and -0.5248, both well inside one standard deviation. Its straight-line distance from the mean is 1.9915. Its Mahalanobis distance is 3.5665, and its square is 12.7199. The point sits across the narrow direction of the cloud, which the z-scores cannot see.
You can reproduce every figure here. Load the first example in the calculator, which holds these ten points and the test point (7, 5), and read the distance, the z-scores and the tag side by side.
The effect grows with correlation. With unit variances and a correlation of 0.9, the point (1.5, -1.5) has a z-score of 1.5 on each variable, yet its distance is 6.7082, which a normal cloud reaches by chance about once in six billion draws (1.69e-10). The point (1.5, 1.5) has the same z-scores and a distance of only 1.5390, with a chance of 0.3060.
The Wikipedia article states the consequence directly: even for a normal distribution, a point can be a multivariate outlier without being a univariate outlier on any variable. The calculator tags that case in words, as an outlier in the joint sense only, so the verdict never rests on colour. A distance is never smaller than the largest z-score, so the tag can only ever go one way.
What whitening does
The definition is a distance after a change of axes. Write the covariance matrix as a product of a factor and its transpose; the Mahalanobis distance is then the ordinary Euclidean length of the point after multiplying by the inverse of the factor. The Wikipedia article on whitening describes the goal: new variables with unit variance and no correlation.
The factor is not unique, and that is useful rather than awkward. The Cholesky decomposition, a lower triangular factor that exists for a positive definite matrix, gives one choice. The symmetric square root, built from the eigenvectors, gives another. The coordinates differ, but both give a length of 3.5665 for the test point, and the page shows the two lengths to twelve digits.
Because the distance is measured after whitening, it ignores units. Multiply the second variable of every point by 100 and the Euclidean distance of the test point jumps to 131.01, since the second variable now dominates the sum. The Mahalanobis distance stays at 3.5665. This is what scale invariance means in practice, and it is why the distance suits variables measured in unrelated units.
Two details separate a correct calculation from a plausible one. First, the page never forms the inverse: it solves a triangular system with the Cholesky factor, which is cheaper and less error-prone. Second, it refuses a covariance matrix with no inverse. Two points in two dimensions give a matrix of rank 1, and a condition number above 1e12 means the inverse would be mostly rounding error. The Wikipedia article on condition numbers explains why such a matrix is dangerous.
Three slips account for most wrong answers. Multiplying by the covariance matrix where its inverse belongs turns the test point’s 3.5665 into 1.1122, a smaller number that points the wrong way. Dividing by N where the estimate needs N minus 1 is the second slip, and comparing the distance, not its square, with a chi-squared table is the third. Each error is small enough to look plausible, which is why the page states its divisor in words, shows the working step by step and keeps the z-scores and the distance side by side, so a mismatch is visible at once.
Why the square follows a chi-squared law
For a multivariate normal distribution, the whitened coordinates are independent standard normal variables. The squared distance is their sum of squares, which is exactly how the chi-squared distribution is built: a sum of squares of independent standard normal variables, with one degree of freedom per variable.
So the chance of a distance at least as large as yours is the upper tail of a chi-squared law of d squared, not of d. Compare d itself against that tail and the test point’s chance becomes 0.1681 instead of 0.0017, a mistake that turns a clear outlier into an unremarkable point.
For two variables the tail has a closed form, exp(-d squared / 2), and the page shows it beside the general routine. For other counts it uses the regularised incomplete gamma function, summed from the series in section 8.7 of the NIST Digital Library of Mathematical Functions and from the continued fraction in section 8.9, with the logarithm of the gamma function taken from the Stirling series in section 5.11.
The law assumes the true mean and covariance. When they come from a table they are estimates, and a point judged against a cloud that includes it looks closer than it is. With ten points, the chance of 0.0017 is a guide for ranking points, not an exact probability.
The same law gives thresholds. The distance below which 95 percent of a normal cloud lies is 2.4477 for two variables, 2.7955 for three and 3.3272 for five. The tail sits further out as variables are added, which is why one fixed distance cannot serve every data set.
A simulation check is easy to run. Two million normal draws in three dimensions have a mean squared distance of about 3.00, matching the three degrees of freedom, and 95.0 percent of them fall below the 2.7955 threshold.
When the cloud judges itself
A distance is only as good as the mean and covariance behind it. The sample mean and sample covariance are sensitive to outliers, and the Wikipedia article on the distance notes that the Minimum Covariance Determinant and Minimum Volume Ellipsoid approaches exist because of this. A few extreme points drag the ellipse towards themselves and shrink their own distances, so an outlier can hide inside the cloud it distorted. This calculator does not offer those estimators; it names them so you know where to look next.
The divisor matters too. A sample covariance divides by N minus 1, the correction that removes the bias in estimating a variance, and the page uses it by default. Dividing by N is correct only when the covariance is known rather than estimated. For the ten points, dividing by N moves the test point’s distance from 3.5665 to 3.7594.
The distance is also tied to leverage. For a table of N observations, the squared distance of each point equals (N - 1) times its leverage minus 1/N, where leverage is the diagonal of the hat matrix of a regression with an intercept. The page computes leverage separately, by orthogonalising the columns, and checks the relation for every observation. For the ten points the farthest observation is number 9, at 2.7417.
The same distance supports classification: estimate a covariance for each class and give a point to the class with the smallest distance, as the Wikipedia article on the distance describes. That is a different task from judging one cloud, and this calculator stops at the distance.
None of this proves a point is wrong. A small chance means a point is unusual under a normal model with these parameters, not that it should be deleted. The chance is also an approximation when the parameters come from a small table. Treat the numbers as a prompt to look at the point, not as a verdict on it.
Sources
Every source consulted for this guide. Links checked November 12, 2026.
- Mahalanobis distance Wikipedia
- Standard score Wikipedia
- Whitening transformation Wikipedia
- Cholesky decomposition Wikipedia
- Condition number Wikipedia
- Bessel's correction Wikipedia
- Chi-squared distribution Wikipedia
- Leverage (statistics) Wikipedia
- Robust statistics Wikipedia
- Chi-Square Distribution NIST Information Technology Laboratory
- DLMF: Series Expansions (section 8.7) NIST Digital Library of Mathematical Functions
- DLMF: Continued Fractions (section 8.9) NIST Digital Library of Mathematical Functions
- DLMF: Asymptotic Expansions (section 5.11) NIST Digital Library of Mathematical Functions
- scipy.spatial.distance.mahalanobis SciPy documentation
- numpy.cov NumPy documentation
- Web Workers API MDN Web Docs
- Intl.NumberFormat MDN Web Docs