Skip to main content

elastic_distance

Function elastic_distance 

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

Compute the elastic distance between two curves.

This is shorthand for aligning the pair and returning only the distance.

§Arguments

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

§Examples

use fdars_core::alignment::elastic_distance;

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 d = elastic_distance(&f1, &f2, &argvals, 0.0);
assert!(d >= 0.0);