mbi.marginal_oracles.message_passing_shafer_shenoy

mbi.marginal_oracles.message_passing_shafer_shenoy(potentials: CliqueVector, total: float = 1, mesh: Mesh | None = None, jtree: Graph | None = None) CliqueVector[source]

Compute marginals from (log-space) potentials using the Shafer-Shenoy algorithm.

This implementation operates completely in logspace, and is more stable than message_passing_stable when potentials contain -inf values. It avoids subtraction of log-probabilities (division in probability space) which can lead to NaNs when dealing with zero probabilities.

Parameters:
  • potentials – The (log-space) potentials of a graphical model.

  • total – The normalization factor.

  • mesh – The mesh over which the computation should be sharded.

  • jtree – An optional junction tree that defines the message passing order.

Returns:

The marginals of the graphical model, defined over the same set of cliques as the input potentials. Each marginal is non-negative and sums to “total”.