pyriemann.geometry.distance.distance_wasserstein¶
- pyriemann.geometry.distance.distance_wasserstein(A, B, squared=False)[source]¶
Wasserstein distance between SPSD/HPSD matrices.
The Wasserstein distance between two SPSD/HPSD matrices \(\mathbf{A}\) and \(\mathbf{B}\) is [1] [2]:
\[d(\mathbf{A},\mathbf{B}) = \sqrt{ \text{tr} \left(\mathbf{A} + \mathbf{B} - 2(\mathbf{B}^{1/2} \mathbf{A} \mathbf{B}^{1/2})^{1/2} \right) }\]- Parameters:
- Andarray, shape (…, n, n)
First SPSD/HPSD matrices.
- Bndarray, shape (…, n, n)
Second SPSD/HPSD matrices, same dimensions as A.
- squaredbool, default=False
Return squared distance.
Added in version 0.5.
- Returns:
- dfloat or ndarray, shape (…,)
Wasserstein distance between A and B.
See also
Notes
Added in version 0.2.4.
Changed in version 0.3: Add broadcasting.
Changed in version 0.5: Add support for HPD matrices.
Changed in version 0.12: Add support for NumPy and PyTorch.
References
[1]An extension of Kakutani’s theorem on infinite product measures to the tensor product of semifinite w*-algebras D. Bures. Trans Am Math Soc, 1969, 135, pp. 199-212
[2]On the Bures–Wasserstein distance between positive definite matrices R. Bhatia, T. Jain, Y. Lim. Expositiones mathematicae, 2019, 37, pp. 165-191.