mixle.inference.belief module¶
Belief states: a distribution over a latent, updated by evidence.
A belief state is the answer-side representation for reasoning: the posterior over a scientific latent given all evidence seen so far. Unlike an embedding vector it is distributional – it carries its own uncertainty – and unlike an LLM’s hidden state it updates by Bayesian conditioning, so folding in a new modality (or a retrieved datum) is a principled evidence step, not a concatenation. That makes multi-source reasoning an assimilation loop: start from the prior, fold in evidence one piece at a time, and watch the posterior entropy shrink.
This module provides the exact, canonical realization – GaussianBelief, a multivariate
Gaussian over a continuous latent with a linear-Gaussian (Kalman) measurement update. Two beliefs
about the same latent fuse as a product of experts (GaussianBelief.fuse()), which is the
cross-modal fusion the reasoning layer is built on. Sequential updates are exact and
order-independent: folding in evidence one datum at a time equals conditioning on all of it at
once – the property the tests check.
Non-Gaussian belief states (mixture/HMM responsibilities, mean-field fields) already exist as
LatentPosterior realizations in mixle.stats.compute.posterior; as_belief() adapts
any object exposing mean/cov into this interface. Nonlinear/EKF and particle updates are
future work (see notes/mixle-cross-modal-reasoning-design.md, Phase 2).
- class BeliefState[source]
Bases:
ABCA distribution over a latent, exposing a uniform query + update interface.
Realizations answer where they are defined:
mean(),cov(),var(),sd(),entropy(),interval(),sample(),marginal(), and – the point of a belief state –update(), which returns a new belief conditioned on fresh evidence.- abstractmethod entropy()[source]
The differential/Shannon entropy
H[q](nats) – watch it shrink as evidence arrives.- Return type:
- abstractmethod sample(n=1, rng=None)[source]
Draw
nlatent samples from the belief.
- abstractmethod update(*args, **kwargs)[source]
Return a new belief conditioned on fresh evidence (the assimilation step).
- interval(level=0.9)[source]
Per-coordinate central credible interval at
level– an(d, 2)array of[lo, hi].
- class CategoricalBelief(probs, labels=None)[source]
Bases:
BeliefStateA belief over a finite hypothesis set – exact Bayes over
Kdiscrete alternatives.The discrete sibling of
GaussianBelief: evidence is a length-Klog-likelihood vectorlog p(y | hypothesis k)andupdate()is the exact posterior (a product of experts in log space).meanreturns the probability vector;entropyis Shannon (nats);mapthe modal hypothesis index.- Parameters:
probs (Any)
labels (Any)
- classmethod uniform(k_or_labels)[source]
- Parameters:
k_or_labels (Any)
- Return type:
CategoricalBelief
- entropy()[source]
The differential/Shannon entropy
H[q](nats) – watch it shrink as evidence arrives.- Return type:
- sample(n=1, rng=None)[source]
Draw
nlatent samples from the belief.
- class GaussianBelief(mean, cov)[source]
Bases:
BeliefStateA multivariate-Gaussian belief
N(mean, cov)over a continuous latent.Evidence is a linear-Gaussian observation
y = H z + noise,noise ~ N(0, R);update()applies the exact Kalman measurement update (Joseph form, so the covariance stays symmetric positive-definite).fuse()combines two beliefs about the same latent as a product of Gaussian experts.condition()does noiseless Gaussian conditioning on a coordinate subset.- Parameters:
mean (Any)
cov (Any)
- property dim: int
- entropy()[source]
The differential/Shannon entropy
H[q](nats) – watch it shrink as evidence arrives.- Return type:
- interval(level=0.9)[source]
Per-coordinate central credible interval at
level– an(d, 2)array of[lo, hi].
- sample(n=1, rng=None)[source]
Draw
nlatent samples from the belief.
- update(H, y, R)[source]
Kalman measurement update: condition on
y = H z + noise,noise ~ N(0, R).
- fuse(other)[source]
Product-of-experts fusion of two beliefs about the same latent (cross-modal fusion).
Equivalent to conditioning
selfonothertreated as a direct Gaussian observation (H = I,R = other.cov), so it reuses the exact Kalman update.- Parameters:
other (GaussianBelief)
- Return type:
GaussianBelief
- condition(indices, values)[source]
Noiseless Gaussian conditioning: fix latent coordinates
indicestovalues.Returns the belief over the remaining coordinates. This is the exact
R -> 0limit of an observation that reads off those coordinates.
- as_belief(obj, node=None)[source]
Adapt any object exposing
mean/cov(aFieldPosteriornode, a fitted Gaussian, aParameterPosterior) into aGaussianBelief.nodeis forwarded when the source is node-addressable (e.g.FieldPosterior.mean(node)/.cov(node)); otherwisemean/covare called with no argument.