mixle.reason.discrete module¶
reason_discrete – fuse multi-source evidence over a finite hypothesis set, with attribution.
The discrete sibling of mixle.reason.core.reason(): the latent is one of K alternatives
(“which regime / fault / explanation”), each evidence source contributes a per-hypothesis
log-likelihood, and the answer is the exact posterior plus how many nats of uncertainty each source
removed. Sources can be raw log-likelihood vectors or fitted mixle models — one generative model
per hypothesis, scored on the raw observation (model_evidence) — so the same distributions you fit
elsewhere become reasoning evidence with no glue.
- model_evidence(name, models, x)[source]
Evidence from fitted mixle models: hypothesis
k<->models[k], scored on observationx.Returns
(name, log_lik)withlog_lik[k] = models[k].log_density(x).
- class DiscreteAnswer(belief, attribution=<factory>)[source]
Bases:
objectThe posterior over hypotheses plus per-source attribution (nats of entropy removed).
- belief: CategoricalBelief
- property probs: ndarray
- decide(loss, actions=None, *, abstain_cost=None)[source]
The Bayes-optimal action under this posterior — EXACT over the finite hypothesis set.
- Parameters:
loss (Any) – an
(A, K)matrix (loss[a, k]= cost of actionawhen hypothesiskis true) or a callableloss(action, hypothesis) -> float.actions (Any) – action labels (defaults to the hypothesis labels — the “declare k” actions).
abstain_cost (float | None) – when given, an extra
"abstain"action with this flat cost — chosen whenever every committal action’s expected loss exceeds it (the escalate-don’t-guess decision, priced explicitly).
- Returns:
{action, expected_loss, alternatives}with the exact expected loss of every candidate.- Return type:
- reason_discrete(prior, evidence)[source]
Fold evidence into a categorical belief and return the posterior with per-source attribution.