Implement more and more logic.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use ndarray::prelude::*;
|
||||
|
||||
use super::Kernel;
|
||||
|
||||
pub struct Constant {
|
||||
@@ -10,4 +12,28 @@ impl Constant {
|
||||
}
|
||||
}
|
||||
|
||||
impl Kernel for Constant {}
|
||||
impl Kernel for Constant {
|
||||
fn k_diag(&self, ts: &[f64]) -> Array1<f64> {
|
||||
Array1::ones(ts.len()) * self.var
|
||||
}
|
||||
|
||||
fn order(&self) -> usize {
|
||||
1
|
||||
}
|
||||
|
||||
fn state_mean(&self, t: f64) -> Array1<f64> {
|
||||
Array1::zeros(1)
|
||||
}
|
||||
|
||||
fn state_cov(&self, t: f64) -> Array2<f64> {
|
||||
array![[1.0]] * self.var
|
||||
}
|
||||
|
||||
fn measurement_vector(&self) -> Array1<f64> {
|
||||
array![1.0]
|
||||
}
|
||||
|
||||
fn transition(&self, t0: f64, t1: f64) -> Array2<f64> {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use ndarray::prelude::*;
|
||||
|
||||
use super::Kernel;
|
||||
|
||||
pub struct Exponential {
|
||||
@@ -11,4 +13,28 @@ impl Exponential {
|
||||
}
|
||||
}
|
||||
|
||||
impl Kernel for Exponential {}
|
||||
impl Kernel for Exponential {
|
||||
fn k_diag(&self, ts: &[f64]) -> Array1<f64> {
|
||||
Array1::ones(ts.len()) * self.var
|
||||
}
|
||||
|
||||
fn order(&self) -> usize {
|
||||
1
|
||||
}
|
||||
|
||||
fn state_mean(&self, t: f64) -> Array1<f64> {
|
||||
Array1::zeros(1)
|
||||
}
|
||||
|
||||
fn state_cov(&self, t: f64) -> Array2<f64> {
|
||||
array![[1.0]] * self.var
|
||||
}
|
||||
|
||||
fn measurement_vector(&self) -> Array1<f64> {
|
||||
array![1.0]
|
||||
}
|
||||
|
||||
fn transition(&self, t0: f64, t1: f64) -> Array2<f64> {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,51 @@
|
||||
use ndarray::prelude::*;
|
||||
|
||||
use super::Kernel;
|
||||
|
||||
pub struct Matern52 {
|
||||
var: f64,
|
||||
l_scale: f64,
|
||||
lambda: f64,
|
||||
}
|
||||
|
||||
impl Matern52 {
|
||||
pub fn new(var: f64, l_scale: f64) -> Self {
|
||||
Matern52 { var, l_scale }
|
||||
Matern52 {
|
||||
var,
|
||||
l_scale,
|
||||
lambda: 5.0f64.sqrt() / l_scale,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Kernel for Matern52 {}
|
||||
impl Kernel for Matern52 {
|
||||
fn k_diag(&self, ts: &[f64]) -> Array1<f64> {
|
||||
Array1::ones(ts.len()) * self.var
|
||||
}
|
||||
|
||||
fn order(&self) -> usize {
|
||||
3
|
||||
}
|
||||
|
||||
fn state_mean(&self, t: f64) -> Array1<f64> {
|
||||
Array1::zeros(3)
|
||||
}
|
||||
|
||||
fn state_cov(&self, t: f64) -> Array2<f64> {
|
||||
let a = self.lambda;
|
||||
|
||||
array![
|
||||
[1.0, 0.0, -a * a / 3.0],
|
||||
[0.0, a * a / 3.0, 0.0],
|
||||
[-a * a / 3.0, 0.0, a.powi(4)]
|
||||
] * self.var
|
||||
}
|
||||
|
||||
fn measurement_vector(&self) -> Array1<f64> {
|
||||
array![1.0, 0.0, 0.0]
|
||||
}
|
||||
|
||||
fn transition(&self, t0: f64, t1: f64) -> Array2<f64> {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user