Mahalanobis Distance Calculator
Enter the point, mean, and covariance values to compute Mahalanobis distance.
Result
How it is calculated
For a two-variable point x = (x1, x2), mean m = (m1, m2) and covariance matrix S = [[s11, s12], [s12, s22]], the tool computes D² = dᵀ S⁻¹ d with d = x − m, then D = √D². The 2×2 inverse is built from the determinant det = s11·s22 − s12²: S⁻¹ = (1/det) · [[s22, −s12], [−s12, s11]]. s11 and s22 are the variances of each variable, s12 is their covariance, all in the squared units of the data. Both D and D² are shown with four decimals. The covariance matrix must be positive definite: s11 and s22 above zero and a determinant above zero, that is s12² < s11·s22. Otherwise (including perfectly correlated variables) no result is shown. All seven fields are required.
Worked example
Point (5, 8), mean (3, 5), s11 = 4, s22 = 9, s12 = 3. The deviation is d = (2, 3). The determinant is 4·9 − 3² = 27, so S⁻¹ = (1/27)·[[9, −3], [−3, 4]]. Then dᵀS⁻¹d = (9·4 − 2·3·2·3 + 4·9)/27 = (36 − 36 + 36)/27 = 1.3333. This is D², and its square root gives a Mahalanobis distance of 1.1547.
Common mistakes
- Entering standard deviations in s11 and s22. These fields take variances (standard deviation squared); a standard deviation of 2 means s11 = 4.
- Entering the correlation coefficient (between −1 and 1) as s12. The covariance is the correlation multiplied by both standard deviations.
- Using an impossible covariance matrix. It needs s12² < s11·s22; with s11 = 4 and s22 = 9, any s12 of 6 or more in size (determinant zero or negative) gives no result.
- Dropping the sign of the covariance. With the same point and mean, s12 = 3 gives D = 1.1547 but s12 = −3 gives D = 2.0000, because the direction of the correlation changes which points count as typical.
- Reading D as D². The tool shows both, and a chi-square cut-off for two variables applies to D², not D.
About this calculator
The Mahalanobis distance measures how far a point is from a distribution's mean, but unlike ordinary Euclidean distance it accounts for the correlation and spread between variables by dividing through the distribution's covariance matrix: D² = (x − μ)ᵀ Σ⁻¹ (x − μ). A point that's far along a direction where the data varies a lot is treated as less unusual than the same distance along a direction where the data barely varies.
This makes it a standard tool in multivariate outlier and anomaly detection, cluster analysis, quality control, and classification — for example flagging fraudulent transactions, detecting faulty sensor readings, or measuring how typical a new observation is relative to a training dataset in machine learning pipelines.
This calculator takes a two-variable point, the distribution's mean, and its 2×2 covariance matrix, then computes the Mahalanobis distance directly. Statisticians, data scientists, and students learning multivariate statistics use it to verify hand calculations or sanity-check outputs from statistical software.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm’s Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Be the first to comment.