spd_learn.functional.mean_alm#

spd_learn.functional.mean_alm(X, *, tol=1e-14, maxiter=100, sample_weight=None, **kwargs)[source]#

Ando-Li-Mathias (ALM) mean of SPD/HPD matrices.

Ando-Li-Mathias (ALM) mean is computed recursively, generalizing from [1]:

\[\mathbf{M} = X_1^{\frac{1}{2}} (X_1^{-\frac{1}{2}}X_2^{\frac{1}{2}} X_1^{-\frac{1}{2}})^{\frac{1}{2}} X_1^{\frac{1}{2}}\]

and requiring a high number of iterations. Extremely slow, due to the recursive formulation.

Parameters:
  • X (ndarray, shape (..., n_matrices, n, n)) – Set of SPD/HPD matrices.

  • tol (float, default=1e-14) – Tolerance to stop the gradient descent.

  • maxiter (int, default=100) – Maximum number of iterations.

  • sample_weight (None | ndarray, shape (n_matrices,), default=None) – Weights for each matrix. If None, it uses equal weights.

Returns:

M – ALM mean.

Return type:

ndarray, shape (…, n, n)

Notes

Added in version 0.3.

Changed in version 0.12: Add support for NumPy and PyTorch.

See also

gmean

References

[1]

Geometric Means T. Ando, C.-K. Li, and R. Mathias. Linear Algebra and its Applications. Volume 385, July 2004, Pages 305-334.