Skip to content

fix: stabilize posterior updates at extreme Bayes factors - #70

Merged
jadenfix merged 2 commits into
mainfrom
fix/posterior-extreme-bayes-factors
Oct 18, 2026
Merged

jadenfix merged 2 commits into
mainfrom
fix/posterior-extreme-bayes-factors

Conversation

@jadenfix

Copy link
Copy Markdown
Owner

Summary

  • compute posterior updates in log-odds space so extreme finite Bayes factors do not overflow through inf / inf
  • treat positive infinity as the limiting posterior 1.0 and reject NaN Bayes factors
  • add focused regressions for the extreme finite, infinite, NaN, and robust-interval boundaries
  • include a reproducible, source-pinned GIF/MP4 comparison with a machine-readable receipt

Reproduced boundary

On base 4e88e771e33bddca3ce3e718da7ed4b531c987d2:

posterior_from_bayes_factor(0.9, 1e308) -> nan
posterior_from_bayes_factor(0.5, inf) -> nan
robust_posterior_interval((0.1, 0.9), (0.5, inf)) -> (..., nan)

At fix commit ec2ad8caeeabbba28252b799cf5ca8101881b641, the same calls return 1.0, 1.0, and (..., 1.0); a NaN Bayes factor raises ValueError.

Verification

  • PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=src python -m pytest -p no:cacheprovider: 426 passed in 1337.38s
  • focused inference suite: 7 passed
  • python -m compileall -q src scripts: 109 files compiled
  • python -m simtheory.experiments: exit 0, 151 output lines
  • additional monotonicity/range grid: 88 boundary combinations
  • MP4: H.264, 960×540, yuv420p, 30 fps, 13.833333 s

Source-pinned media

The receipt compares base 4e88e771e33bddca3ce3e718da7ed4b531c987d2 with fix ec2ad8caeeabbba28252b799cf5ca8101881b641 by loading inference.py directly from both Git revisions. It also records the focused test command and verified paths.

  • docs/media/posterior-boundary-demo.gif — SHA-256 4caa0bacdec47f69132ff9c36c1325cceebc47ce07f33e2007f031f58115bfc9
  • docs/media/posterior-boundary-demo.mp4 — SHA-256 1fa27eaf90e27551f220519aa56f40be249b9caff99eb13a435d3a40905f4224
  • docs/media/posterior-boundary-demo-receipt.json — SHA-256 5349d9d86e9b6b71e263fb6904e469cc046bebc5fe403b7fe6b34eddda98ee51

Scientific boundary

This is a numerical-stability and input-validation fix. It does not validate any supplied likelihood model, change identifiability assumptions, or provide evidence for any simulation hypothesis.

Copy link
Copy Markdown
Owner Author

Independent exact-head review — CLEAR

Reviewed exact head bef838efa89e346d940ed87e7f0c3385e1bdebde.

  • Stable log-odds implementation avoids finite-BF overflow.
  • Boundary contract verified: BF 0 → posterior 0; positive infinity → 1; NaN/negative/non-finite-negative inputs reject.
  • Independent 117-case high-precision comparison plus monotonicity/range probes passed.
  • Focused inference suite passed 7/7; full suite passed 426 tests on Python 3.11, 3.12, and 3.13.
  • PR-triggered rerun is fully green: https://github.com/jadenfix/simulation-theory/actions/runs/38411588888
  • Current PR state recalculated as clean and mergeable.
  • All six changed files have zero path overlap with the repository's 20 pre-existing draft PRs.
  • Fresh renderer execution reproduced GIF, MP4, and receipt byte-for-byte.
  • Full GIF and MP4 decoding plus representative-frame inspection passed.
  • Working tree remained clean.

This is narrowly a numerical-stability/input-validation repair. It does not validate likelihood models or provide evidence for any simulation hypothesis.

No blocker found. Ready for designated sole-merger review; not merged here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant