pub struct BayesianNetworkInference { /* private fields */ }Expand description
Bayesian network inference engine.
Supports variable elimination (exact), belief propagation (sum-product), and likelihood-weighted sampling.
Implementations§
Source§impl BayesianNetworkInference
impl BayesianNetworkInference
Sourcepub fn new(
network: BayesianNetwork,
config: BniConfig,
) -> Result<Self, BniError>
pub fn new( network: BayesianNetwork, config: BniConfig, ) -> Result<Self, BniError>
Create and validate a new inference engine.
Returns an error if:
- the network contains a directed cycle,
- any CPT references an undefined variable,
- any CPT has incorrect dimensions.
Sourcepub fn query(
&mut self,
q: &InferenceQuery,
) -> Result<Vec<QueryResult>, BniError>
pub fn query( &mut self, q: &InferenceQuery, ) -> Result<Vec<QueryResult>, BniError>
Run an inference query and return per-variable posterior distributions.
Sourcepub fn prior_marginal(
&mut self,
variable: &str,
) -> Result<QueryResult, BniError>
pub fn prior_marginal( &mut self, variable: &str, ) -> Result<QueryResult, BniError>
Compute the prior marginal for a single variable (no evidence).
Sourcepub fn add_cpt(
&mut self,
cpt: ConditionalProbabilityTable,
) -> Result<(), BniError>
pub fn add_cpt( &mut self, cpt: ConditionalProbabilityTable, ) -> Result<(), BniError>
Add a new CPT to the network after construction.
Validates dimensions and checks for duplicate variables.
Auto Trait Implementations§
impl Freeze for BayesianNetworkInference
impl RefUnwindSafe for BayesianNetworkInference
impl Send for BayesianNetworkInference
impl Sync for BayesianNetworkInference
impl Unpin for BayesianNetworkInference
impl UnsafeUnpin for BayesianNetworkInference
impl UnwindSafe for BayesianNetworkInference
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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