pub fn karcher_mean(
data: &FdMatrix,
argvals: &[f64],
max_iter: usize,
tol: f64,
lambda: f64,
) -> KarcherMeanResultExpand description
Compute the Karcher (Frechet) mean in the elastic metric.
Iteratively aligns all curves to the current mean estimate in SRSF space, computes the pointwise mean of aligned SRSFs, and reconstructs the mean curve.
§Arguments
data— Functional data matrix (n × m)argvals— Evaluation points (length m)max_iter— Maximum number of iterationstol— Convergence tolerance for the SRSF mean
§Returns
KarcherMeanResult with mean curve, warping functions, aligned data, and convergence info.
§Examples
use fdars_core::simulation::{sim_fundata, EFunType, EValType};
use fdars_core::alignment::karcher_mean;
let t: Vec<f64> = (0..50).map(|i| i as f64 / 49.0).collect();
let data = sim_fundata(20, &t, 3, EFunType::Fourier, EValType::Exponential, Some(42));
let result = karcher_mean(&data, &t, 20, 1e-4, 0.0);
assert_eq!(result.mean.len(), 50);
assert!(result.n_iter <= 20);