Skip to content

Add an affine-invariant ensemble sampler - #573

Open
BJMCox wants to merge 20 commits into
mainfrom
add-affine-invariant-ensemble
Open

Add an affine-invariant ensemble sampler#573
BJMCox wants to merge 20 commits into
mainfrom
add-affine-invariant-ensemble

Conversation

@BJMCox

@BJMCox BJMCox commented Aug 31, 2026

Copy link
Copy Markdown
Member

This adds a native Goodman--Weare stretch move to TransformedMCMC, without adding a sampler dependency.

  • updates each ensemble with balanced red-blue moves;
  • treats each BAT chain as one independent ensemble;
  • computes ESS from the full-sweep ensemble-mean process;
  • keeps convergence checks between independent ensembles;
  • validates walker count, transformed affine rank, retry initialization, and supported weighting;
  • reports per-ensemble acceptance counts and rates;
  • documents the experimental API and its limits.

StretchMove requires an explicit nwalkers, at least 2d walkers, full-rank transformed initialization, and RepetitionWeighting. Affine invariance does not solve multimodality, and acceptance rate is not treated as convergence evidence.

Validation:

  • focused StretchMove tests;
  • MCMC and statistics test groups;
  • strict docs and doctests;
  • clean Pkg.test();
  • independent statistical, performance, architecture, code-quality, and code-smell reviews.

BenchmarkTools measurements confirm one target-density call per walker per full sweep and linear walker scaling. Reusing the proposed transformed-state buffer cut the measured transition allocations without changing the proposal values or RNG stream.

BJMCox added 18 commits August 31, 2026 17:14
Define the affine-invariant proposal and validate its ensemble before sampling. Reject unsupported weighting and proposal combinations instead of applying invalid defaults.
Apply the Goodman-Weare move in two ordered ensemble halves so each complement stays fixed during proposal generation. Reuse BAT's bookkeeping and RNG partitions without copying the full ensemble per walker.
Estimate autocorrelation from each full-sweep ensemble mean so cross-walker lag dependence remains in the variance calculation. Pool only independent BAT ensembles and decline estimates when exact path alignment is unavailable.
StretchMove has no proposal or transform tuning, so burn-in has no acceptance target to satisfy. Mark its fixed proposal state as tuned and retain normal cycle and convergence handling.
Check affine equivariance and known moments on correlated Gaussian and controlled non-Gaussian targets. Keep convergence groups aligned with independent ensembles rather than coupled walkers.
Document the coupled-ensemble contract and its diagnostic limits. Record allocation, density-call, and timing evidence for representative low- and moderate-dimensional workloads.
Revalidate affine rank after retry initialization and compute stretch factors without overflowing finite scales. Report proposal acceptance counters without treating them as convergence evidence.
Share proposal validation and step finalization without changing transition order. Reuse unshaped repetition data and remove small sources of duplicate work.
Route StretchMove through a private atomic ensemble sweep with supported sequential and threaded executors. Preserve walker-keyed streams and exact sequential samples while rejecting distributed execution before sampling.
Implement current-complement differential evolution proposals with dimension-resolved scaling and distinct ordered companion draws. Reuse the shared atomic ensemble sweep for deterministic sequential and threaded execution.
Implement four-group differential-evolution snooker proposals with the exact Hastings correction and deterministic executor behavior. Reject degenerate directions before target evaluation while preserving the current walker state.
Reject zero and nonfinite q-z directions before transform or target evaluation. Reuse the validated reverse-direction norm in the exact Hastings correction and cover both rejection paths.
Apply an active ensemble component to one complete walker sweep while retaining the existing integer and categorical selection rules. Enforce ensemble weighting, fixed-transform, and pooled-ESS contracts without disabling ordinary component proposal tuning.
Reject adaptive mixture-weight tuning when an ensemble component has no target-acceptance model. Let top-level no-tuning treat ensemble components as tuning-successful while retaining ordinary component acceptance checks.
Add calibrated deterministic stationary-moment coverage for the ensemble moves and their weighted mixture. Document proposal laws, constraints, mixtures, and executor behavior without claiming convergence or general performance.
Name the shared documentation sections without implying every ensemble move is affine-invariant. Limit the affine-equivariance statement to Stretch and DE, and define the Stretch scale notation.
Retain independent move, executor, atomicity, RNG, and stationary-law checks while removing snapshots and duplicate fixture coverage.

Keep the sequential Stretch fast path and use one shared test seam for the remaining ensemble contracts.
Route sequential and generic Stretch walkers through one evaluation kernel while retaining the sequential RNG-partition schedule.

Remove private and type-only ensemble checks while preserving observable transition, atomicity, RNG, and compatibility coverage.
@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.88889% with 104 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.18%. Comparing base (6e8795f) to head (c242887).

Files with missing lines Patch % Lines
src/samplers/mcmc/ensemble_move.jl 70.63% 37 Missing ⚠️
src/samplers/mcmc/mcmc_multiproposal.jl 0.00% 34 Missing ⚠️
src/samplers/mcmc/stretch_move.jl 76.00% 12 Missing ⚠️
src/samplers/mcmc/de_snooker_move.jl 80.43% 9 Missing ⚠️
src/samplers/mcmc/de_move.jl 88.37% 5 Missing ⚠️
...plers/mcmc/mcmc_tuning/mcmc_multiproposal_tuner.jl 0.00% 2 Missing ⚠️
src/samplers/mcmc/mcmc_algorithm.jl 83.33% 1 Missing ⚠️
src/samplers/mcmc/mcmc_sample.jl 98.94% 1 Missing ⚠️
src/samplers/mcmc/mcmc_state.jl 97.05% 1 Missing ⚠️
.../mcmc/mcmc_tuning/mcmc_adaptive_multiprop_tuner.jl 0.00% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #573      +/-   ##
==========================================
+ Coverage   65.45%   66.18%   +0.73%     
==========================================
  Files         121      125       +4     
  Lines        7060     7485     +425     
==========================================
+ Hits         4621     4954     +333     
- Misses       2439     2531      +92     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Consolidate shared ensemble policy and remove redundant tests without changing transition behavior. Fix mixture initialization and retry validation gaps found during final review.
@BJMCox
BJMCox force-pushed the add-affine-invariant-ensemble branch from 984f45a to e12d101 Compare September 1, 2026 12:06
Mixtures rebuilt transformed walker coordinates and repeated identical ensemble validation for each component. Reusing the existing coordinates and sharing the invariant checks removes duplicate work while preserving move-specific limits and six-argument compatibility.
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