Skip to content

Add exact-posterior sampler tests; update NEWS and contributors for #425-#428 - #431

Merged
andrewherren merged 3 commits into
mainfrom
mcmc-exact-posterior-tests
Oct 5, 2026
Merged

andrewherren merged 3 commits into
mainfrom
mcmc-exact-posterior-tests

Conversation

@andrewherren

Copy link
Copy Markdown
Collaborator

Follow-up to the sampler and random effects fixes from @dwachsmuth in #425, #426, #427, and #428.

Exact-posterior tests (R and Python)

test/python/test_mcmc_exact_posterior.py and test/R/testthat/test-mcmc-exact-posterior.R check the MCMC tree sampler against an exactly known answer. On a single-tree problem with four observations (one covariate with values 1-4, zero outcomes, alpha = 0.6, beta = 2, min_samples_leaf = 1, fixed unit variances), every tree can be enumerated, so the posterior over the number of leaves is known exactly (50.183 / 42.176 / 7.196 / 0.446%). A 100,000-draw chain must match each share to within 1 percentage point (more than 5 Monte Carlo standard errors).

The covariate is fed in ascending and descending order. The posterior is the same either way, but the order changes which observation each node scans first when computing its split range, which is how the #425 bug shows up. Before the fixes, the descending case never split at all.

Verified against local builds of each stage, in both languages:

Build ascending descending
main before #425/#426 fail fail
#426 only pass fail
#425 only fail fail
#425 + #426 (current main) pass pass

Runtime is about 3 s in Python and about 9 s in R; the R sampler test uses skip_on_cran().

NEWS and contributors

🤖 Generated with Claude Code

andrewherren and others added 3 commits October 4, 2026 21:11
On a 4-observation, single-tree problem every tree can be enumerated,
so the posterior over the number of leaves is known exactly. A 100k-draw
chain must match it to within 1 percentage point, for the covariate in
ascending and descending order. Fails on main (wrong MH acceptance ratio,
and the VarSplitRange extrema bug, which stops descending-order nodes
from ever splitting); passes with #425 and #426 applied.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Add Bug Fixes entries for #425, #426, #427, and #428, noting that they
change sampler output for a given seed, and add David Wachsmuth as a
contributor in DESCRIPTION and the package Rd.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@andrewherren
andrewherren merged commit 74d6769 into main Oct 5, 2026
16 checks passed
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