pyriemann.geometry.distance.distance_mahalanobis¶
- pyriemann.geometry.distance.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:
- Xndarray, shape (…, n, m)
Vectors.
- covndarray, shape (…, n, n)
Covariance matrix of the multivariate Gaussian distribution.
- meanNone | ndarray, shape (…, n, 1), default=None
Mean vector of the multivariate Gaussian distribution. If None, distribution is considered as centered.
- squaredbool, default=False
Return squared distance.
Added in version 0.5.
- Returns:
- dndarray, shape (…, m)
Mahalanobis distances.
Notes
Added in version 0.4.
Changed in version 0.12: Add support for NumPy and PyTorch.
References