Skip to content

MCMC diagnostics + ensemble uncertainty: plots, EnsembleEnergy, disagreement OOD - #53

Merged
davidkhjo merged 4 commits into
mainfrom
diagnostics-ensemble
Aug 20, 2026
Merged

MCMC diagnostics + ensemble uncertainty: plots, EnsembleEnergy, disagreement OOD#53
davidkhjo merged 4 commits into
mainfrom
diagnostics-ensemble

Conversation

@davidkhjo

Copy link
Copy Markdown
Owner

Two threads that make EBMs easier to trust: is the sampler mixing? and is this input in-distribution?

Diagnostics

  • eval.autocorrelation(samples, max_lag) — mean per-chain ACF ρ̂_t (FFT, the same autocovariance as effective_sample_size).
  • viz.autocorrelation_plot (with a ±1.96/√N band), viz.rank_plot (Vehtari rank histograms — uniform under good mixing), viz.trace_plot.

Ensemble uncertainty

  • EnsembleEnergy — a deep-ensemble mean energy E = (1/N)ΣE_i (the geometric-mean density; equals SumEnergy with weights 1/N), deliberately distinct from MixtureEnergy's logsumexp. Adds member_energies and disagreement (per-sample variance across members).
  • eval.ensemble_disagreement — that variance, batched, as an epistemic OOD score.

Validation (closed-form / distributional)

  • ACF estimator matches an AR(1)'s ρ^t (to N-error).
  • Ensemble of Gaussian-energy members reproduces the closed-form combined Gaussian variance 1/mean(1/σ_i²) exactly.
  • Member disagreement separates in-distribution from OOD at AUROC ≈ 1; rank plots are uniform for matched chains and skewed for an offset chain.

Notes

  • Example ensemble_ood.py: a 3-member ensemble on two-moons; disagreement flags a Gaussian blob at AUROC ≈ 1.
  • torch-only; public API preserved; accumulates under the unreleased 0.15.0. This completes the E1–E6 roadmap; NUTS and the latent/hierarchical EBM (E7) are left as follow-ups (NUTS deferred because a correct batched implementation is easy to bias silently — against this library's correctness-first stance).

🤖 Generated with Claude Code

davidkhjo and others added 4 commits August 20, 2026 17:06
EnsembleEnergy pools members into a MEAN energy (the geometric-mean density,
distinct from MixtureEnergy's logsumexp), with member_energies and a per-sample
disagreement (variance across members). eval.ensemble_disagreement exposes that
variance batched as an epistemic OOD score.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
viz.autocorrelation_plot (with a +/-1.96/sqrt(N) band), rank_plot (Vehtari rank
histograms), and trace_plot, backed by the numeric eval.autocorrelation. Reuse
the ESS FFT-autocovariance and _as_chains coercion.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Ensemble reproduces the closed-form combined Gaussian variance and its
disagreement separates OOD at AUROC ~1; the ACF estimator matches an AR(1)'s
rho^t; rank-plot uniformity for matched chains and skew for an offset chain.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A 3-member deep-ensemble EBM whose member disagreement flags OOD (two-moons vs a
Gaussian blob, AUROC ~1). README eval/composition/viz rows + examples list and the
unreleased CHANGELOG updated.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@davidkhjo
davidkhjo merged commit f61331a into main Aug 20, 2026
5 checks passed
@davidkhjo davidkhjo mentioned this pull request Aug 20, 2026
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