definition overview

A belief is what travels along an edge of a factor graph and what sits on a variable: a representation of a probability distribution, or of a likelihood, over that variable’s space. Concrete representations include points, particles, Gaussians, finite distributions, mixtures, and callable likelihood potentials. Their pooling operation is combine.

Sources: original to this vault (design); code: open_model.jl (AbstractBelief, DiracBelief, SampleBelief, TrivialBelief), gaussian_belief.jl (GaussianBelief), messages.jl (combine, belief_distance, belief_logdensity)

Theory (CT-ML wiki): Giry Monad · Markov Category · Bayesian Inversion · Distribution Monad

What a belief is

Categorically, a belief on a variable is an element of , a state in a Markov category (for continuous spaces, the Giry monad). It is the prior of a Bayesian lens and the posterior that inference returns. On an edge it may also be a likelihood: a non-negative function that need not integrate to one, which is why some beliefs are allowed to be improper.

All belief types subtype LenticulumCore.AbstractBelief and are defined in LenticulumCore, GaussianBelief included (it moved there from the top-level package in October 2026, so that every factor package can emit one); their message rules are in Mycelium. The diffusion factors now return Laplace Gaussians on request; the equilibrium factors still return points (DEQ as a Relation §5).

The belief representations

typerepresentswhereisexacttypical source
Trivial Beliefno information (the unit)LenticulumCoretruean unset message, the prior of a prior
Dirac Beliefa point mass, LenticulumCoretruean observation (a hard clamp), a point inference
Gaussian Belief in canonical form , possibly improperLenticulumCorefalse (the default)Gaussian factors, Laplace approximations
Sample Beliefa weighted particle setLenticulumCorefalsesamplers, the fallback
Categorical Beliefa distribution over finitely many statesLenticulumCorefalsediscrete variables, switches, Bernoulli events
Mixture Beliefa weighted sum of beliefs of one typeLenticulumCorefalseseveral answers at once (branches), Gaussian-sum filters

AbstractPotentialBelief names improper likelihoods known through a log-density up to an additive constant. LogPotentialBelief(logφ) wraps the callable; it has no sampling, mean, or entropy contract. Richer subtypes can expose gradients, a parametric form, or batched evaluation. RatioFactor emits this type; see ratio and open_model.

isexact says whether a computed belief is exact rather than approximate. It defaults to false so that silence never implies exactness; only the Trivial and Dirac beliefs override it. A Gaussian can be exact (on a linear-Gaussian tree it is), but the flag does not claim it.

The algebra: combine

Pooling two beliefs about one variable is the pointwise product of their densities, the sum–product step at a variable node (Messages are Inversions). Mycelium.combine implements exactly the cases it can do exactly:

combineresultwhy
Trivial with anythingthe otherthe unit
Gaussian with Gaussianadd exact, associative, commutative
Dirac with Gaussian, Sample or Trivialthe Diraca hard clamp is the limit and dominates
two equal Diracsthat Diracidempotent
two different Diracserrorcontradictory hard clamps are a modelling error
Categorical with Categoricalelementwise product, renormalisedexact and total; error only for disjoint supports
Sample with a density or potentialthe samples, reweighted by that densityimportance reweighting
Potential with potentialsum log-potentialsproduct, without normalisation
Gaussian, categorical, or mixture with an arbitrary potentialerroran exact product needs more structure
Mixture with supported beliefseach component pooled, weights scaled by its overlapexact for Gaussian and categorical components
two Sample beliefserrorneither has a density; project one first (moment_match)
anything elseerrorno rule for the pair

So beliefs form a partial commutative monoid under combine, with the Trivial belief as unit and the Dirac beliefs as absorbing elements. Gaussians and categoricals are closed under it, which is why Gaussian belief propagation is exact on trees (The Linear Gaussian Chain); mixtures are closed too, at the price of growing (reduce_mixture bounds them). The rest of the catalogue (addition, logic, projection, tempering) is in Belief Algebra.

Other operations

  • belief_distance(a, b) — how much a message changed, the convergence test of propagate!. It returns Inf whenever it cannot tell, so that a schedule never declares convergence it cannot verify.
  • belief_logdensity(b, x) — ; for Gaussians, categoricals (x a state or label), mixtures, and callable log-potentials.
  • moment_match(b) — the Gaussian with the same mean and covariance (samples, Gaussian mixtures); the projection step of expectation propagation.
  • reduce_mixture(m; max_components) — merge Gaussian mixture components, preserving mean and covariance.
  • variable_entropy(b) — the entropy in the Bethe Free Energy; for Gaussians it can be negative.

Everything else one might do with beliefs (addition, mixture, logic, projection, tempering) is catalogued, with what each needs, in Belief Algebra.

Related: Messages are Inversions, Factor Graphs, Channels and Polarity, Inversions and Bayesian Lenses, Probabilistic Types

Docs: Lenticulum API · Mycelium API

using Lenticulum, LenticulumCore, Mycelium
using LenticulumCore: DiracBelief, TrivialBelief, SampleBelief
a = Gaussian(1.0, 4.0); b = Gaussian(3.0, 4.0)       # N(1, 4) and N(3, 4), stored as (η, Λ)
c = combine(a, b)                                     # pooling = adding canonical parameters
(belief_mean(c), belief_cov(c))                       # ≈ ([2.0], [2.0;;]): precision-weighted mean, halved variance
combine(TrivialBelief(), a) === a                     # true: the unit
u = uninformative(1); combine(u, a).η == a.η          # true: (0, 0) is the same unit in canonical form
combine(DiracBelief([0.5]), a)                        # the Dirac: a hard clamp dominates (Λ → ∞)
lik = GaussianBelief([2.0, 0.0], [1.0 0.0; 0.0 0.0])  # constrains x₁ only: an improper likelihood message
isproper(lik)                                         # false — fine for a message, not for a mean
belief_mean(combine(lik, Gaussian([0.0, 0.0], [1.0 0.0; 0.0 1.0])))   # ≈ [1.0, 0.0]: proper after a prior