Mahalanobis distance is a multivariate statistical measure of the distance between a data point and a distribution, defined as the number of standard deviations the point is from the distribution's mean. Crucially, it accounts for the correlations between variables and the scale of each dimension by incorporating the distribution's covariance matrix. This makes it superior to Euclidean distance for analyzing data where variables are interdependent or have different units.
Glossary
Mahalanobis Distance

What is Mahalanobis Distance?
A statistical distance metric fundamental to probabilistic state estimation and outlier detection in robotics and sensor fusion.
In sensor fusion and state estimation, it is used for outlier rejection (e.g., identifying erroneous LiDAR scans) and data association (e.g., matching observed features to map landmarks). It provides a probabilistic gate, often within a Kalman filter, by evaluating how well a new measurement aligns with the filter's predicted state and its associated uncertainty. Its value follows a chi-squared distribution, enabling statistical significance testing.
Key Properties of Mahalanobis Distance
The Mahalanobis distance is a multivariate statistical distance that accounts for the correlations and variances within a dataset. Its core properties make it indispensable for robust state estimation and outlier detection in robotics.
Scale and Correlation Invariance
Unlike Euclidean distance, the Mahalanobis distance is scale-invariant and accounts for correlations between variables. It standardizes the data using the inverse of the covariance matrix (Σ⁻¹). This means a unit change in one variable is weighted according to its variance and its relationship with other variables. For example, in a robot's state vector where position (meters) and velocity (m/s) are correlated, the distance correctly measures deviations without being skewed by differing units or scales.
Probabilistic Interpretation
The squared Mahalanobis distance follows a chi-squared (χ²) distribution when the data point is drawn from the assumed multivariate normal distribution. This provides a direct statistical test for outlier rejection. In a Kalman filter, the innovation (difference between predicted and actual measurement) is often evaluated using its Mahalanobis distance. If the squared distance exceeds a threshold based on the χ² distribution (e.g., for 3 degrees of freedom, a 95% confidence threshold is ~7.81), the measurement is flagged as an outlier and can be rejected.
Ellipsoidal Iso-Distance Contours
Points with an equal Mahalanobis distance from the distribution mean form ellipsoids in the variable space. The shape and orientation of these ellipsoids are defined by the eigenvectors and eigenvalues of the covariance matrix. This geometrically represents regions of equal probability density for a multivariate Gaussian.
- The principal axes of the ellipsoid align with the directions of maximum variance.
- This visualizes why a point can be close in Euclidean terms but far in Mahalanobis terms if it lies in a direction of low variance.
Central Role in Kalman Filtering
The Mahalanobis distance is fundamental to the Kalman filter update step. The filter's Kalman gain is computed to minimize the posterior error covariance, which is intrinsically linked to this distance metric. The innovation covariance (S = HPHᵀ + R) acts as the covariance matrix for calculating the Mahalanobis distance of the incoming measurement. This ensures the filter update is optimally weighted based on the current state uncertainty (P) and sensor noise (R).
Data Association in Multi-Target Tracking
In multi-object tracking and SLAM data association, the Mahalanobis distance is used within the nearest neighbor or global nearest neighbor methods to assign new sensor observations to existing tracks or map landmarks. It compares a predicted measurement (from a track) to a candidate observation. The assignment that minimizes the Mahalanobis distance is statistically the most likely correct match, as it considers the uncertainty in the prediction.
Sensitivity to Distribution Shape
A key property is its sensitivity to the shape of the underlying distribution. It effectively measures distance in terms of standard deviations from the mean along the principal components. This means:
- A small shift in a direction of high variance results in a small Mahalanobis distance.
- The same magnitude shift in a direction of low variance results in a large Mahalanobis distance. This property is critical for detecting anomalies that are unusual given the observed correlation structure, not just large in a raw numerical sense.
Mahalanobis Distance vs. Euclidean Distance
A direct comparison of two distance metrics, highlighting their mathematical properties and suitability for state estimation and outlier detection in robotics.
| Feature / Property | Mahalanobis Distance | Euclidean Distance |
|---|---|---|
Core Definition | A statistical distance between a point and a distribution, accounting for variable correlations and scales. | The geometric 'straight-line' distance between two points in Euclidean space. |
Mathematical Formula | √[(x - μ)ᵀ Σ⁻¹ (x - μ)] | √[Σᵢ (xᵢ - yᵢ)²] |
Accounts for Variable Correlation | ||
Scale-Invariant (Unitless) | ||
Sensitive to Data Distribution | ||
Primary Use Case in Robotics | Probabilistic outlier rejection, data association, gating in Kalman filters, evaluating measurement likelihood. | Geometric calculations, clustering in normalized feature spaces, nearest-neighbor search in pre-processed data. |
Computational Complexity | Higher (requires covariance matrix Σ and its inverse Σ⁻¹). | Lower (simple sum of squared differences). |
Interpretation of Distance | Number of standard deviations a point is from the mean of the distribution. | Absolute spatial separation in the input coordinate units. |
Effect of Highly Correlated Features | Reduces the effective distance, as the distribution is elongated along the correlation direction. | Inflates the distance, treating correlated dimensions as independent contributions. |
Frequently Asked Questions
The Mahalanobis distance is a fundamental statistical measure in robotics and state estimation. These FAQs address its core mechanics, applications, and relationship to other key concepts in sensor fusion.
The Mahalanobis distance is a statistical measure of the distance between a point and a distribution, which accounts for the correlations between variables and the scale of each dimension. Unlike Euclidean distance, it measures distance in terms of standard deviations from the mean of the distribution.
It works by first inverting the distribution's covariance matrix to decorrelate and normalize the data space. The formula is: D_M(x) = sqrt((x - μ)^T Σ^{-1} (x - μ)), where x is the data point, μ is the distribution mean, and Σ is the covariance matrix. A large Mahalanobis distance indicates the point is an outlier relative to the expected multivariate distribution.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Mahalanobis distance is a fundamental statistical tool within probabilistic state estimation. These related concepts define the mathematical and algorithmic frameworks where it is applied.
Covariance Matrix
A covariance matrix is a square matrix that quantifies the uncertainty of a state vector and the correlations between its components. In state estimation, it represents the estimated error of the system.
- Diagonal elements represent the variance (uncertainty) of each state variable.
- Off-diagonal elements represent the covariance (correlation) between different state variables.
- The Mahalanobis distance calculation directly uses the inverse of the covariance matrix to account for these correlations when measuring distance.
- In a Kalman filter, the covariance matrix is propagated and updated alongside the state estimate.
Outlier Rejection
Outlier rejection is the process of identifying and discarding sensor measurements that are statistically inconsistent with the current state estimate. The Mahalanobis distance is the primary metric for this task.
- A measurement's innovation (difference from prediction) is computed.
- The Mahalanobis distance of this innovation is calculated using the innovation covariance.
- If the squared Mahalanobis distance exceeds a threshold (e.g., based on a chi-squared distribution), the measurement is flagged as an outlier.
- This is critical for maintaining robustness against erroneous data from sensor failures or environmental noise.
Kalman Filter
A Kalman filter is an optimal recursive algorithm for estimating the state of a linear dynamic system from noisy measurements. The Mahalanobis distance is implicitly used within its update step.
- The filter maintains a state estimate and a covariance matrix representing estimation uncertainty.
- It operates in a predict-update cycle: predict the state forward, then update with a new measurement.
- The Kalman gain determines how much to trust the new measurement versus the prediction.
- The innovation and its covariance are used to compute a form of Mahalanobis distance to assess measurement consistency.
Gating (Data Association)
Gating is a technique in multi-target tracking and SLAM used for data association—the problem of determining which sensor observation corresponds to which tracked object or map feature. Mahalanobis distance defines the validation gate.
- A validation region (gate) is established around a predicted measurement.
- The gate is typically an ellipsoid defined by a Mahalanobis distance threshold.
- Only observations falling within this ellipsoid are considered potential matches for the track.
- This efficiently reduces combinatorial complexity by pruning unlikely associations before more expensive matching algorithms run.
Multivariate Normal Distribution
The multivariate normal (Gaussian) distribution is a generalization of the one-dimensional normal distribution to multiple, potentially correlated variables. The Mahalanobis distance is the distance measure native to this distribution.
- It is fully characterized by a mean vector (center) and a covariance matrix (spread and orientation).
- Contours of constant probability density are ellipsoids centered at the mean.
- The squared Mahalanobis distance from a point to the distribution's mean is proportional to the negative log-likelihood of that point.
- Most probabilistic state estimators (KF, EKF, UKF) assume state uncertainty is modeled by this distribution.
Chi-Squared Distribution
The chi-squared distribution is a theoretical probability distribution that arises in statistical hypothesis testing. It provides the statistical basis for setting thresholds when using the Mahalanobis distance for outlier detection.
- If a random vector
xis distributed according to a multivariate normal distribution, then the squared Mahalanobis distance ofxfollows a chi-squared distribution. - The degrees of freedom equal the dimensionality of
x. - A common practice is to reject a measurement as an outlier if its squared Mahalanobis distance exceeds the 95th or 99th percentile of the corresponding chi-squared distribution.
- This provides a statistically principled method for threshold selection.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us