Skip to main content

Module probabilistic

Module probabilistic 

Source
Expand description

Probabilistic abduction — Bayesian scoring and ranking of competing hypotheses.

Among the hypotheses that could explain an observation, the best is the most probable a posteriori: P(h | obs) ∝ P(h) · P(obs | h) (prior × likelihood), normalised over the candidates. Zero-heap (caller-supplied out).

Structs§

Hypothesis
A candidate abductive hypothesis: its id, Bayesian prior P(h), and the likelihood it assigns to the observation P(obs | h). Both in [0, ∞) (typically [0,1]).

Functions§

bayesian_posteriors
Posteriors P(h | obs) ∝ prior·likelihood, normalised over hyps, written into out (parallel to hyps). Returns the evidence P(obs) = Σ prior·likelihood (the normaliser); if it is ~0 (no hypothesis explains the observation) out is filled with zeros and 0.0 is returned. Refuses on a length mismatch by returning 0.0 without writing.
best_hypothesis
The maximum-a-posteriori hypothesis id — the one with the greatest prior·likelihood (argmax of the posterior; normalisation is monotone so it needs no division). None if hyps is empty or carries no probability mass.