Added TernaryModel.

This commit is contained in:
2020-03-06 09:49:55 +01:00
parent 8fe57b4649
commit 67d1412af8
5 changed files with 426 additions and 171 deletions

View File

@@ -13,10 +13,10 @@ pub struct RecursiveFitter {
#[derivative(Debug = "ignore")]
kernel: Box<dyn Kernel>,
ts: Vec<f64>,
ms: ArrayD<f64>,
vs: Array1<f64>,
ns: ArrayD<f64>,
xs: ArrayD<f64>,
ms: ArrayD<f64>, // TODO Replace with a vec
vs: Array1<f64>, // TODO Replace with a vec
ns: ArrayD<f64>, // TODO Replace with a vec
xs: ArrayD<f64>, // TODO Replace with a vec
is_fitted: bool,
h: Array1<f64>,
i: Array2<f64>,
@@ -181,16 +181,10 @@ impl Fitter for RecursiveFitter {
} else {
let a = self.p_p[i + 1].clone();
let b = self.a[i].dot(&self.p_f[i]);
// println!("a={:#?}", a);
let g = crate::linalg::solve(a, b);
let g = g.t();
/*
let g = self.a[i]
.dot(&self.p_f[i])
.dot(&self.p_p[i + 1].inv().expect("failed to inverse matrix"));
*/
self.m_s[i] = &self.m_f[i] + &g.dot(&(&self.m_s[i + 1] - &self.m_p[i + 1]));
self.p_s[i] =
&self.p_f[i] + &g.dot(&(&self.p_s[i + 1] - &self.p_p[i + 1])).dot(&g.t());
@@ -257,6 +251,7 @@ impl Fitter for RecursiveFitter {
let a = self.kernel.transition(ts[i], self.ts[(j + 1) as usize]);
let a = a.dot(&p);
let b = self.p_p[(j + 1) as usize].clone();
let g = crate::linalg::solve(a, b);
let g = g.t();