pub struct JunctionTree { /* private fields */ }Expand description
A calibrated (or calibratable) junction tree for exact inference.
Implementations§
Source§impl JunctionTree
impl JunctionTree
Sourcepub fn build(
cfg: &JunctionTreeConfig,
factors: &[(Vec<usize>, Vec<f64>)],
) -> SeqResult<Self>
pub fn build( cfg: &JunctionTreeConfig, factors: &[(Vec<usize>, Vec<f64>)], ) -> SeqResult<Self>
Build a junction tree from a list of factors.
Each factor is (vars, table) where vars is the (unsorted is allowed)
scope and table is a linear-domain non-negative potential table,
row-major over the factor’s joint configuration in the given vars
order. Tables are converted to the log domain internally.
Sourcepub fn calibrate(&mut self) -> SeqResult<()>
pub fn calibrate(&mut self) -> SeqResult<()>
Run Hugin two-pass message passing (collect to root, distribute from root)
so that every clique stores its joint marginal (scaled by Z) and every
separator is consistent with both incident cliques.
Sourcepub fn marginal(&self, var: usize) -> SeqResult<Vec<f64>>
pub fn marginal(&self, var: usize) -> SeqResult<Vec<f64>>
Marginal distribution over a single variable after calibration, normalised to sum to 1.
Sourcepub fn clique_marginal(&self, clique_idx: usize) -> SeqResult<Vec<f64>>
pub fn clique_marginal(&self, clique_idx: usize) -> SeqResult<Vec<f64>>
Joint marginal over the variables of clique clique_idx, normalised to sum
to 1. The output is row-major over the clique’s (sorted) variables.
Sourcepub fn log_partition(&self) -> SeqResult<f64>
pub fn log_partition(&self) -> SeqResult<f64>
Log partition function log Z (log of the normalisation constant).
After calibration every clique sums (in the linear domain) to Z, so we
take the log-sum-exp of any clique’s log-potential. Before calibration this
is generally not Z; callers should calibrate first.
Sourcepub fn n_separators(&self) -> usize
pub fn n_separators(&self) -> usize
Number of separators (tree edges) in the tree.
Sourcepub fn separator_vars(&self, sep_idx: usize) -> SeqResult<&[usize]>
pub fn separator_vars(&self, sep_idx: usize) -> SeqResult<&[usize]>
Variables of separator sep_idx (sorted); useful for tests checking the
running-intersection property.
Trait Implementations§
Source§impl Clone for JunctionTree
impl Clone for JunctionTree
Source§fn clone(&self) -> JunctionTree
fn clone(&self) -> JunctionTree
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more