pyriemann.utils.distance.distance_wasserstein

pyriemann.utils.distance.distance_wasserstein(A, B, squared=False)

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, at least 2D ndarray.

Bndarray, shape (…, n, n)

Second SPSD/HPSD matrices, same dimensions as A.

squaredbool, default False

Return squared distance.

New in version 0.5.

Returns:
dfloat or ndarray, shape (…,)

Wasserstein distance between A and B.

See also

distance

References

[1]

Optimal transport: old and new C. Villani. Springer Science & Business Media, 2008, vol. 338