pyriemann.utils.distance.distance_riemann

pyriemann.utils.distance.distance_riemann(A, B)

Affine-invariant Riemannian distance between SPD matrices.

The affine-invariant Riemannian distance between two SPD matrices A and B is:

\[d(\mathbf{A},\mathbf{B}) = {\left( \sum_i \log(\lambda_i)^2 \right)}^{1/2}\]

where \(\lambda_i\) are the joint eigenvalues of \(\mathbf{A}\) and \(\mathbf{B}\).

Parameters
Andarray, shape (…, n, n)

First SPD matrices, at least 2D ndarray.

Bndarray, shape (…, n, n)

Second SPD matrices, same dimensions as A.

Returns
dndarray, shape (…,) or float

Affine-invariant Riemannian distance between A and B.