mixle.reason.belief_walk module¶
Reasoning as a belief walk across a chain of verified transports.
A multi-hop reasoning path, such as binding -> structure -> activity,
transports a belief at each hop. This module composes fitted conditional
transports from fit_cycle_transport() by
Monte Carlo forward simulation: draw from the belief at hop 0, push the sample
through hop 1’s transport, and continue through the chain. The result is an
empirical posterior over the final variable whose spread reflects uncertainty
from every intervening hop.
Composition is gated on the edge premise: a transport that has not been
verified usable and calibrated on its own edge is refused before composition.
coverage_by_hop_count() checks calibration by hop count with a two-sided
binomial test against nominal coverage, so degradation across composed hops is
measured rather than assumed.
- class HopTransport(name, fit, premise_passed=True)[source]
Bases:
objectOne edge of the belief walk and its own calibration verdict.
premise_passedrecords whether this transport was independently verified usable and calibrated on this edge.
- class WalkResult(hop_names, samples)[source]
Bases:
objectThe belief walk’s outcome: an empirical posterior over the final hop’s variable.
- property mean: ndarray
Return posterior sample mean for the final hop.
- property std: ndarray
Return posterior sample standard deviation for the final hop.
- belief_walk(hops, x0, *, n_draws=200, seed=0)[source]
Propagate a belief forward through a chain of hops, starting from a single value
x0.Each hop’s transport is applied by drawing
n_drawssamples of the current belief and pushing each through the hop’ssample_givenmethod. Raises if any hop’spremise_passedflag isFalse.
- coverage_by_hop_count(hops, x0_test, true_final, *, alpha=0.1, n_draws=150, seed=0)[source]
Return empirical calibration by hop count.
For
k = 1 .. len(hops), walks the firstkhops for every test point inx0_testand checks credible-interval coverage oftrue_final[k]against the nominal1 - alpharate with a two-sided binomial test.true_finalmust supply ground truth for each checked hop count.