Skip to main content

elastic_align_pair

Function elastic_align_pair 

Source
pub fn elastic_align_pair(
    f1: &[f64],
    f2: &[f64],
    argvals: &[f64],
    lambda: f64,
) -> AlignmentResult
Expand description

Align curve f2 to curve f1 using the elastic framework.

Computes the optimal warping γ such that f2∘γ is as close as possible to f1 in the elastic (Fisher-Rao) metric.

§Arguments

  • f1 — Target curve (length m)
  • f2 — Curve to align (length m)
  • argvals — Evaluation points (length m)
  • lambda — Penalty weight on warp deviation from identity (0.0 = no penalty)

§Returns

AlignmentResult with warping function, aligned curve, and elastic distance.

§Examples

use fdars_core::alignment::elastic_align_pair;

let argvals: Vec<f64> = (0..20).map(|i| i as f64 / 19.0).collect();
let f1: Vec<f64> = argvals.iter().map(|&t| (t * 6.0).sin()).collect();
let f2: Vec<f64> = argvals.iter().map(|&t| ((t + 0.1) * 6.0).sin()).collect();
let result = elastic_align_pair(&f1, &f2, &argvals, 0.0);
assert_eq!(result.f_aligned.len(), 20);
assert!(result.distance >= 0.0);