pyriemann.utils.distance.distance_riemann

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

Affine-invariant Riemannian distance between SPD/HPD matrices.

The affine-invariant Riemannian distance between two SPD/HPD matrices \(\mathbf{A}\) and \(\mathbf{B}\) is [1]:

\[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/HPD matrices, at least 2D ndarray.

Bndarray, shape (…, n, n)

Second SPD/HPD matrices, same dimensions as A.

squaredbool, default False

Return squared distance.

New in version 0.5.

Returns:
dfloat or ndarray, shape (…,)

Affine-invariant Riemannian distance between A and B.

See also

distance

References

[1]

A differential geometric approach to the geometric mean of symmetric positive-definite matrices M. Moakher. SIAM J Matrix Anal Appl, 2005, 26 (3), pp. 735-747