Fréchet Mean (Karcher Flow)
The Riemannian generalization of the arithmetic mean: the point minimizing the sum of squared geodesic distances to a set of input points.
Algorithm Summary
| Property | Value |
|---|---|
| Function | frechet_mean |
| Config | FrechetConfig |
| Trait requirements | Manifold (exp + log only) |
| Convergence | Linear; global on Cartan-Hadamard manifolds () |
| Weighted variant | Yes: pass per-point weights |
Definition
Karcher flow gradient step:
Repeat until is below tolerance.
FrechetConfig
pub struct FrechetConfig {
pub max_iters: usize, // default: 200
pub tol: f64, // default: 1e-8 - stop when gradient norm < tol
pub step_size: f64, // default: 1.0 - Karcher step size (1.0 = exact gradient flow)
}Code Examples
Mean of points on S²
use cartan::prelude::*;
use cartan::manifolds::Sphere;
use cartan_optim::{frechet_mean, FrechetConfig};
let s2 = Sphere::<3>;
let mut rng = rand::rng();
let points: Vec<_> = (0..20).map(|_| s2.random_point(&mut rng)).collect();
// init = None → uses points[0] as starting estimate
let mean = frechet_mean(&s2, &points, None, &FrechetConfig::default());
assert!(mean.converged);Custom initial estimate
// Provide a custom starting point for the Karcher iteration
let init = s2.random_point(&mut rng);
let mean = frechet_mean(&s2, &points, Some(init), &FrechetConfig::default());Numerical Notes
Convergence radius: Karcher flow converges to the global minimum only when the points are contained within a geodesic ball of radius less than . Outside this radius there may be multiple local minima.
Initialization: frechet_mean initializes at the first input point when None is passed.
For widely spread data, consider running from multiple initializations.
Negative curvature: on Cartan-Hadamard manifolds (SPD with affine-invariant metric, ), the Fréchet mean is unique and Karcher flow converges globally.
Compared to minimize_rgd: use frechet_mean (not RGD on the sum-of-squares
objective; it exploits the special structure of the objective and is numerically
more stable.
Applications
- Averaging rotation matrices: SO(3) mean for sensor fusion
- Covariance averaging: SPD mean for brain-computer interfaces / fMRI
- Directional statistics: mean of unit vectors on
- Point cloud alignment: Fréchet mean of SE(3) poses in SLAM