pyriemann.utils.median_euclid¶
- pyriemann.utils.median_euclid(X, *, tol=1e-05, maxiter=50, init=None, weights=None)¶
Euclidean geometric median of matrices.
The Euclidean geometric median minimizes the sum of Euclidean distances \(d_E\) to all matrices [1] [2]:
\[\arg \min_{\mathbf{M}} \sum_i w_i \ d_E (\mathbf{M}, \mathbf{X}_i)\]Geometric median is different from the marginal median provided by NumPy [3].
- Parameters:
- Xndarray, shape (n_matrices, n, m)
Set of matrices.
- tolfloat, default=10e-6
The tolerance to stop the iterative algorithm.
- maxiterint, default=50
The maximum number of iterations.
- initNone | ndarray, shape (n, m), default=None
A matrix used to initialize the iterative algorithm. If None, the weighted Euclidean mean is used.
- weightsNone | ndarray, shape (n_matrices,), default=None
Weights for each matrix. If None, it uses equal weights.
- Returns:
- Mndarray, shape (n, m)
Euclidean geometric median.
Notes
Added in version 0.4.
References
[1]Sur le point pour lequel la somme des distances de n points donnés est minimum E Weiszfeld. Tohoku Mathematical Journal, 1937, 43, pp. 355-386.
[2]The multivariate L1-median and associated data depth Y Vardi and C-H Zhan. Proceedings of the National Academy of Sciences, 2000, vol. 97, no 4, p. 1423-1426