pub struct BayesianUpdateEngine { /* private fields */ }Expand description
Bayesian belief updating engine.
Maintains a bounded history of Posterior results and supports both
single-step updates and sequential folding of multiple observations.
Implementations§
Source§impl BayesianUpdateEngine
impl BayesianUpdateEngine
Sourcepub fn update(
&mut self,
prior: Prior,
observation: &Observation,
) -> Result<Posterior, BayesError>
pub fn update( &mut self, prior: Prior, observation: &Observation, ) -> Result<Posterior, BayesError>
Perform a single Bayesian update, returning the posterior.
The method validates parameters and dispatches to the appropriate conjugate-update formula.
Sourcepub fn sequential_update(
&mut self,
prior: Prior,
observations: &[Observation],
) -> Result<Posterior, BayesError>
pub fn sequential_update( &mut self, prior: Prior, observations: &[Observation], ) -> Result<Posterior, BayesError>
Apply a sequence of observations left-to-right, using each posterior as the prior for the next update.
Returns the final posterior, or an error at the first failing update.
Sourcepub fn credible_interval(
posterior: &Prior,
probability: f64,
) -> Result<CredibleInterval, BayesError>
pub fn credible_interval( posterior: &Prior, probability: f64, ) -> Result<CredibleInterval, BayesError>
Compute a symmetric credible interval for a posterior distribution.
Uses normal / Wilson approximations — suitable for moderate-to-large concentration parameters.
§Arguments
posterior– the posterior distribution.probability– the desired probability mass (e.g.0.95).
Sourcepub fn map_estimate(posterior: &Prior) -> f64
pub fn map_estimate(posterior: &Prior) -> f64
Return the maximum a posteriori (MAP) estimate for a distribution.
| Distribution | MAP |
|---|---|
| Beta(α,β) | (α-1)/(α+β-2) if α>1 && β>1, else α/(α+β) |
| Gaussian(μ,σ²) | μ |
| Gamma(k,r) | (k-1)/r if k>1, else 0 |
| Dirichlet(α) | argmax(αᵢ) / Σαᵢ |
Sourcepub fn kl_divergence(p: &Prior, q: &Prior) -> Result<f64, BayesError>
pub fn kl_divergence(p: &Prior, q: &Prior) -> Result<f64, BayesError>
Compute the KL divergence KL(p ‖ q) between two distributions of the same family.
Supported pairs: Beta vs Beta, Gaussian vs Gaussian.
All other combinations return BayesError::UnsupportedOperation.
Sourcepub fn history(&self) -> &VecDeque<Posterior>
pub fn history(&self) -> &VecDeque<Posterior>
Immutable reference to the update history (oldest first).
Sourcepub fn clear_history(&mut self)
pub fn clear_history(&mut self)
Clear the update history.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BayesianUpdateEngine
impl RefUnwindSafe for BayesianUpdateEngine
impl Send for BayesianUpdateEngine
impl Sync for BayesianUpdateEngine
impl Unpin for BayesianUpdateEngine
impl UnsafeUnpin for BayesianUpdateEngine
impl UnwindSafe for BayesianUpdateEngine
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more