The Mahalanobis distance is a unitless, scale-invariant metric that measures the distance between a point and a distribution by accounting for the covariance among variables. Unlike Euclidean distance, which assumes spherical, uncorrelated data, it effectively normalizes by the variance along each principal component, making it the preferred metric for out-of-distribution detection in correlated feature spaces.
Glossary
Mahalanobis Distance

What is Mahalanobis Distance?
A multivariate distance measure that scales by the covariance structure of a distribution, enabling statistically informed outlier and novelty detection.
In open set signal recognition, the Mahalanobis distance is computed between a test sample's embedding and the class-conditional mean of a known modulation. A large distance, often thresholded using a chi-squared distribution, signals a novel or unknown class. This provides a principled, closed-form alternative to learned rejection layers like OpenMax, grounded directly in the statistical properties of the training data.
Core Properties
The Mahalanobis distance provides a multivariate effect size measure that accounts for the covariance structure of a class distribution, making it a foundational tool for statistically informed novelty detection in open set signal recognition.
Covariance-Aware Scaling
Unlike Euclidean distance, which treats all dimensions equally, the Mahalanobis distance scales the separation along each principal component by the inverse of the covariance matrix. This effectively transforms the feature space into a unit-variance sphere, ensuring that a deviation along a low-variance, highly correlated direction is weighted more heavily than the same deviation along a high-variance, noisy axis. This prevents the classifier from being misled by spurious correlations in the IQ sample or cumulant feature space.
Out-of-Distribution Scoring
In open set recognition, the Mahalanobis distance serves as a powerful confidence score. A deep network is first trained on known modulation classes. The class-conditional Gaussian distributions are then fitted to the learned embeddings by computing a class mean vector and a shared or per-class covariance matrix. At inference, the minimum Mahalanobis distance from a query sample to any known class centroid is calculated. If this distance exceeds a calibrated threshold, the sample is flagged as an unknown or novel modulation.
Generative Classifier Equivalence
Using the Mahalanobis distance for classification is mathematically equivalent to a Gaussian Discriminant Analysis classifier with a shared covariance matrix. The decision boundary becomes a linear hyperplane. This property bridges discriminative deep learning with generative probability density estimation, allowing the model to not only predict a class label but also estimate the likelihood of the input belonging to the training distribution, which is critical for detecting distributional shift.
Robust Covariance Estimation
The standard empirical covariance estimator is highly sensitive to outliers and can be singular in high-dimensional feature spaces with limited samples. For reliable Mahalanobis distance calculation, robust estimators are essential:
- Minimum Covariance Determinant: Finds an outlier-free subset of the data to compute a stable covariance matrix.
- Shrinkage Estimators: Combine the sample covariance with a structured target matrix to reduce estimation error and guarantee invertibility.
- Empirical Bayes Ridge: Adds a regularization term to the diagonal of the covariance matrix, stabilizing the inverse.
Feature Space Deep Whitening
A key preprocessing step for effective Mahalanobis-based detection is deep whitening. After the final embedding layer, a transformation matrix derived from the inverse square root of the covariance matrix is applied. This linear operation decorrelates the features and normalizes their variances to unity. In this whitened space, the Mahalanobis distance reduces to a simple Euclidean distance, allowing for computationally efficient nearest-centroid classification and novelty detection without repeated matrix inversions.
Limitations in High Dimensions
The Mahalanobis distance relies on the assumption that the class-conditional data is unimodal and Gaussian. In the highly nonlinear embedding spaces of deep networks, this assumption often breaks down. The distance can also suffer from the curse of dimensionality, where the volume of the covariance ellipsoid concentrates at a thin shell, making all points appear equidistant. For complex, multi-modal signal distributions, a mixture of Gaussians or a non-parametric k-Nearest Neighbor distance in the whitened space often provides a more reliable novelty score.
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.
Frequently Asked Questions
Explore the core concepts behind using the Mahalanobis distance as a statistically robust metric for detecting unknown modulation schemes and out-of-distribution signals in cognitive radio systems.
The Mahalanobis distance is a multi-dimensional generalization of the standard score that measures the distance between a point and a distribution. Unlike Euclidean distance, which measures straight-line geometric distance, the Mahalanobis distance accounts for the covariance structure of the underlying data distribution. It works by transforming the feature space into a space where the data is uncorrelated and has unit variance, then computing the Euclidean distance in this transformed space. Mathematically, for a point ( x ) and a distribution with mean ( \mu ) and covariance matrix ( \Sigma ), the distance is defined as ( D_M(x) = \sqrt{(x - \mu)^T \Sigma^{-1} (x - \mu)} ). This effectively re-scales the axes according to the data's natural variance, so a deviation along a low-variance principal component is penalized more heavily than the same deviation along a high-variance component. In signal classification, this means a new IQ sample is evaluated not just by its raw value, but by how statistically typical it is for a given modulation class.
Related Terms
Understanding the Mahalanobis distance requires familiarity with the statistical and geometric concepts that underpin its use in open-set signal recognition.
Covariance Matrix
The core statistical object that differentiates Mahalanobis distance from Euclidean distance. It captures the variance of each feature and the correlation between feature pairs in a dataset.
- Defines the shape and orientation of a class's distribution.
- The Mahalanobis distance effectively uses the inverse of this matrix to whiten or decorrelate the data.
- In signal classification, it models the natural spread of IQ samples for a specific modulation scheme under noise.
Euclidean Distance
The straight-line, 'as-the-crow-flies' distance between two points. It assumes all features are equally important and completely uncorrelated.
- Computationally simple but statistically naive for correlated data.
- Fails to recognize that a point far from the mean in a low-variance direction is more anomalous than a point equally far in a high-variance direction.
- Mahalanobis distance reduces to Euclidean distance when the covariance matrix is the identity matrix.
Out-of-Distribution Detection
The primary application of Mahalanobis distance in this domain. A sample is flagged as unknown if its Mahalanobis distance to the nearest known class prototype exceeds a calibrated threshold.
- Provides a principled statistical test for novelty.
- More robust than SoftMax confidence scores, which can be arbitrarily high for unknown inputs.
- Often used to fit a class-conditional Gaussian distribution in a learned feature space.
Feature Space Whitening
A preprocessing transformation that decorrelates data and scales it to unit variance. Computing the Euclidean distance on whitened data is mathematically equivalent to computing the Mahalanobis distance on the original data.
- Involves multiplying data by the inverse square root of the covariance matrix.
- Creates an isotropic, spherical distribution where standard distance metrics become valid.
- A key step in many deep open-set classifiers to simplify the geometry of the embedding space.
Chi-Squared Distribution
The theoretical probability distribution that squared Mahalanobis distances follow if the original data is multivariate Gaussian. This allows for a rigorous statistical threshold to be set for novelty detection.
- The degrees of freedom equal the dimensionality of the feature space.
- A threshold can be set based on a desired confidence level (e.g., 99.9%) to reject outliers.
- Deviation from this distribution in the tail can be modeled using Extreme Value Theory for more accurate open-set calibration.
Prototype Learning
A classification strategy where the network learns a single representative embedding vector, or prototype, for each known modulation class. The Mahalanobis distance to these prototypes serves as the direct decision metric.
- Replaces a linear classification layer with a distance-based one.
- Enforces a compact, Gaussian-like feature distribution around each prototype during training.
- Enables open-set rejection by simply thresholding the minimum distance to any known prototype.

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