pyriemann.utils.distance.distance_mahalanobis

pyriemann.utils.distance.distance_mahalanobis(X, cov, mean=None)

Mahalanobis distance between vectors and a Gaussian distribution.

The Mahalanobis distance between a vector \(x\) and a Gaussian distribution \(\mathcal{N}(\mu, C)\), with mean \(\mu\) and covariance matrix \(C\), is:

\[d(x, \mathcal{N}(\mu, C)) = \sqrt{ (x - \mu)^H C^{-1} (x - \mu) }\]
Parameters
Xndarray, shape (n_channels, n_vectors)

Multi-channel vectors.

covndarray, shape (n_channels, n_channels)

Covariance matrix of the Gaussian distribution.

meanNone | ndarray, shape (n_channels, 1), default=None

Mean of the Gaussian distribution. If None, distribution is considered as centered.

Returns
dndarray, shape (n_vectors,)

Mahalanobis distances.

Notes

New in version 0.3.1.

References

1

https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.mahalanobis.html