OMG, I'm close now!

This commit is contained in:
2020-02-20 14:36:44 +01:00
parent 6840699144
commit 9ac7e44776
5 changed files with 50 additions and 11 deletions

View File

@@ -1,3 +1,4 @@
use derivative::Derivative;
use ndarray::prelude::*;
use ndarray::stack;
use ndarray_linalg::Inverse;
@@ -6,8 +7,11 @@ use crate::kernel::Kernel;
use super::Fitter;
#[derive(Derivative)]
#[derivative(Debug)]
pub struct RecursiveFitter {
ts_new: Vec<f64>,
#[derivative(Debug = "ignore")]
kernel: Box<dyn Kernel>,
ts: Vec<f64>,
ms: ArrayD<f64>,
@@ -122,7 +126,7 @@ impl Fitter for RecursiveFitter {
fn fit(&mut self) {
if !self.is_allocated() {
// raise RuntimeError("new data since last call to `allocate()`")
panic!("new data since last call to `allocate()`");
}
if self.ts.is_empty() {
@@ -146,7 +150,7 @@ impl Fitter for RecursiveFitter {
let k = Array1::from(k);
self.m_f[i] =
(&self.m_p[i] + &k) * (&self.ns[i] - &self.xs[i] * &self.h.dot(&self.m_p[i]));
&self.m_p[i] + &(&k * (&self.ns[i] - &self.xs[i] * &self.h.dot(&self.m_p[i])));
// Covariance matrix is computed using the Joseph form.
let outer = (self.xs[i] * &k)