Skip to main content

Gaussian

Struct Gaussian 

Source
pub struct Gaussian {
    pub mean: Vec<f64>,
    pub cov: Vec<f64>,
    /* private fields */
}

Fields§

§mean: Vec<f64>

Posterior mean — length D.

§cov: Vec<f64>

Posterior covariance, row-major D×D.

Implementations§

Source§

impl Gaussian

Source

pub fn new(mean: Vec<f64>, cov: Vec<f64>) -> Result<Self, BLRError>

Create a new Gaussian, validating dimensions.

Source

pub fn dim(&self) -> usize

Dimension D of the distribution.

Source

pub fn std(&self) -> Vec<f64>

Per-dimension standard deviations: sqrt(diag(cov)).

Source

pub fn marginal(&self, i: usize) -> (f64, f64)

Marginal distribution at index i: returns (mean[i], std[i]).

Source

pub fn log_pdf(&self, x: &[f64]) -> f64

Log probability density log N(x; mean, cov).

Uses Cholesky of cov for numerical stability.

Source

pub fn condition( self, a: &[f64], n_obs: usize, d_feat: usize, y: &[f64], noise_variance: f64, ) -> Result<Self, BLRError>

Bayesian update: computes p(self | y) where y = A·self + ε, ε ~ N(0, σ²·I_N) (homoscedastic noise).

a is the measurement matrix A (n_obs × d_feat), row-major flat slice. noise_variance is the scalar observation noise variance σ² > 0.

§Adaptive dispatch

Two algebraically equivalent forms are available; this method selects whichever minimises the size of the required Cholesky factorisation:

ConditionForm chosenCholesky size
n_obs < d_featGram / Kalman-gain (observation-space)N×N
n_obs >= d_featPrecision / Woodbury (parameter-space)D×D

The two forms are related by the Woodbury matrix identity; see dev/blog/blr-and-ard.md Appendix A for the derivation. The precision form derives Σ_prior⁻¹ directly from self.cov — no isotropic approximation is made, and the forms agree within floating-point rounding error.

Returns the updated Gaussian representing the posterior distribution.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,