spd_learn.functional.distance_mahalanobis#
- spd_learn.functional.distance_mahalanobis(X, cov, mean=None, squared=False)[source]#
Mahalanobis distance between vectors and a Gaussian distribution.
The Mahalanobis distance between a vector \(x \in \mathbb{C}^n\) and a multivariate Gaussian distribution \(\mathcal{N}(\mu, C)\), with mean vector \(\mu \in \mathbb{C}^n\) and covariance matrix \(C \in \mathbb{C}^{n \times n}\) , is:
\[d(x, \mathcal{N}(\mu, C)) = \sqrt{ (x - \mu)^H C^{-1} (x - \mu) }\]- Parameters:
X (ndarray, shape (..., n, m)) – Vectors.
cov (ndarray, shape (..., n, n)) – Covariance matrix of the multivariate Gaussian distribution.
mean (None | ndarray, shape (..., n, 1), default=None) – Mean vector of the multivariate Gaussian distribution. If None, distribution is considered as centered.
squared (bool, default=False) –
Return squared distance.
Added in version 0.5.
- Returns:
d – Mahalanobis distances.
- Return type:
ndarray, shape (…, m)
Notes
Added in version 0.4.
Changed in version 0.12: Add support for NumPy and PyTorch.
References