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}) = \Vert \log(\mathbf{B}^{-1/2} \mathbf{A} \mathbf{B}^{-1/2}) \Vert_F = {\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.
Added in version 0.5.
- Returns:
- dfloat or ndarray, shape (…,)
Affine-invariant Riemannian distance between A and B.
See also
References
[1]A metric for covariance matrices W. Förstner & B. Moonen. Geodesy-the Challenge of the 3rd Millennium, 2003