mod arx;
mod frequency_response;
mod gpr;
mod iv;
mod oe;
mod sml;
mod srivc;
use dsmc::TransferFunction;
const TOL_LSM_ARX: f64 = 1e-6;
const TOL_KF_ARX: f64 = 1e-6;
const TOL_LSM_POLY: f64 = 1e-8;
const TOL_KF_POLY: f64 = 1e-8;
const TOL_LEVY: f64 = 1e-6;
const TOL_VF: f64 = 1e-8;
fn tf_distance<D: dsmc::Domain>(a: &TransferFunction<f64, D>, b: &TransferFunction<f64, D>) -> f64 {
let normalize = |tf: &TransferFunction<f64, D>| {
let k = tf.denominator[0];
let n: Vec<f64> = tf.numerator.iter().map(|c| c / k).collect();
let d: Vec<f64> = tf.denominator.iter().map(|c| c / k).collect();
(n, d)
};
let (na, da) = normalize(a);
let (nb, db) = normalize(b);
assert_eq!((na.len(), da.len()), (nb.len(), db.len()), "orders differ: {a:?} vs {b:?}");
na.iter().zip(&nb).chain(da.iter().zip(&db)).map(|(x, y)| (x - y).abs()).fold(0.0, f64::max)
}