Calculator Inputs
Example Data Table
This example matches the preloaded values. Expected output is D² ≈ 1.3711 and D ≈ 1.1710.
| Variable | Observation | Mean |
|---|---|---|
| A | 7 | 5 |
| B | 4 | 3 |
| C | 9 | 8 |
| A | B | C | |
|---|---|---|---|
| A | 4 | 1 | 0.5 |
| B | 1 | 3 | 0.2 |
| C | 0.5 | 0.2 | 2 |
Formula Used
Squared Mahalanobis Distance:
D² = (x − μ)T Σ−1 (x − μ)
Mahalanobis Distance:
D = √D²
Here, x is the observation vector, μ is the mean vector, and Σ−1 is the inverse covariance matrix. This method adjusts for both scale and correlation, which makes it more informative than ordinary Euclidean distance in multivariate analysis.
How to Use This Calculator
- Enter the observation vector you want to evaluate.
- Enter the mean vector using the same order and length.
- Paste the covariance matrix with one row per line.
- Optionally add variable labels for cleaner result tables and charts.
- Select a chi-square cutoff level and your preferred decimal precision.
- Click Calculate Distance to see the result above the form.
- Review D, D², matrix details, and the Plotly contribution chart.
- Use the CSV or PDF buttons to export the report.
FAQs
1. What does Mahalanobis distance measure?
It measures how far an observation lies from a multivariate center while accounting for variable scale and correlation. It is often used for outlier detection, clustering, and similarity analysis.
2. Why is the covariance matrix important?
The covariance matrix captures how variables vary together. Using its inverse lets the distance shrink along common variation patterns and expand across unusual directions.
3. What does a large D² value mean?
A large squared distance means the observation is far from the center after accounting for covariance structure. It may indicate an unusual point or possible outlier.
4. Can I use a singular covariance matrix?
No. A singular matrix cannot be inverted, so the distance is undefined in the standard formula. Remove redundant variables or use a regularized covariance estimate.
5. Should I standardize variables first?
Usually not when your covariance matrix already reflects the data properly. Mahalanobis distance inherently adjusts for scale through covariance, unlike Euclidean distance.
6. How many variables can I enter?
You can enter any dimension that remains computationally reasonable in your environment, provided the covariance matrix is square, valid, and invertible.
7. How do I decide whether a point is an outlier?
A common approach compares D² with a chi-square critical value using degrees of freedom equal to the number of variables. Larger values may signal an outlier.
8. What is the difference between D and D²?
D² is the quadratic form used in many statistical tests. D is its square root, which can be easier to read when comparing distances directly.