csrk 1.1.4

Sparse Gaussian Process regression with compactly supported radial kernels
Documentation
//! Gaussian Process realizations (random function draws)

// Standard library modules
// Third Party
use ndarray::ArrayView1;
// Local
use crate::GP;
/// A reproducible realization stream of a Gaussian Process 
pub struct GPRealization<'a> { 
    /// Reference to the GP
    gp: &'a GP,
    /// Posterior at training points
    f_train: Vec<f64>,
    // beta = K^{-1} f_train
    /// Cached so production is cheap
    beta: Vec<f64>,
    /// Random noise
    #[allow(unused)]
    z_train: Vec<f64>, // optional, for debugging
}

impl<'a> GPRealization<'a> {
    /// Constructor
    pub(crate) fn new(
        gp: &'a GP,
        f_train: Vec<f64>,
        beta: Vec<f64>,
        z_train: Vec<f64>,
    ) -> Self {
        Self { gp, f_train, beta, z_train}
    }
    /// Return training points
    pub fn at_training_points(&self) -> &[f64] {
        &self.f_train
    }
    /// Estimate value
    pub fn value(&self, x: ArrayView1<f64>) -> f64 {
        let mut val = 0.;
        self.gp.for_each_kernel_entry(x, |i, kij| {
            val += kij * self.beta[i];
        });
        val
    }
}