pyriemann.utils.mean.mean_riemann

pyriemann.utils.mean.mean_riemann(X, *, tol=1e-08, maxiter=50, init=None, sample_weight=None)

Mean of SPD/HPD matrices according to the Riemannian metric.

The affine-invariant Riemannian mean minimizes the sum of squared affine-invariant Riemannian distances \(d_R\) to all SPD/HPD matrices [1]:

\[\arg \min_{\mathbf{M}} \sum_i w_i \ d_R (\mathbf{M}, \mathbf{X}_i)^2\]

For the convergence, the implemented stopping criterion comes from [2].

Parameters:
Xndarray, shape (n_matrices, n, n)

Set of SPD/HPD matrices.

tolfloat, default=10e-9

Tolerance to stop the gradient descent.

maxiterint, default=50

Maximum number of iterations.

initNone | ndarray, shape (n, n), default=None

A SPD/HPD matrix used to initialize the gradient descent. If None, the weighted Euclidean mean is used.

sample_weightNone | ndarray, shape (n_matrices,), default=None

Weights for each matrix. If None, it uses equal weights.

Returns:
Mndarray, shape (n, n)

Affine-invariant Riemannian mean.

See also

mean_covariance

References

[1]

Principal geodesic analysis for the study of nonlinear statistics of shape P.T. Fletcher, C. Lu, S. M. Pizer, S. Joshi. IEEE Trans Med Imaging, 2004, 23(8), pp. 995-1005

[2]

Approximate Joint Diagonalization and Geometric Mean of Symmetric Positive Definite Matrices M. Congedo, B. Afsari, A. Barachant, M. Moakher. PLOS ONE, 2015