Skip to content

Add reference-value precision gate for MCMC diagnostics (ar, ac, ess, statistics, gelmanRubin) #1279

Description

@synesenom

Goal

Establish systematic reference-value testing for deterministic MCMC diagnostic functions (ar(), ac(), ess(), statistics(), gelmanRubin()) to verify their numerical accuracy against canonical implementations and document their truncation conventions.

Scope

  • Fixed synthetic chains as test inputs — AR(1) sequences with known theoretical autocorrelation, plus iid and strongly-correlated sequences. Synthetic chains allow reference values derived from theory rather than just comparing against another implementation.
  • Reference values from R (coda::effectiveSize, coda::gelman.diag) and/or Stan's posterior package, recorded with package versions and exact calls.
  • Document the truncation convention ranjs uses for ac()/ess() and state explicitly whether it matches coda, Stan, both, or neither.
  • Cover ar() (acceptance rate), ac() (autocorrelation), ess() (effective sample size), statistics() (summary statistics), and gelmanRubin() (R-hat convergence diagnostic).

Acceptance Criteria

  • Precision gate covers all five functions (ar, ac, ess, statistics, gelmanRubin) against fixed synthetic chains with documented sources.
  • Reference values sourced from R/coda or Stan with package versions and exact calls recorded; theoretical AR(1) autocorrelation used where exact checks are possible.
  • The ac/ess truncation convention is identified and documented in the test file, with explicit statement of whether it matches coda, Stan, both, or neither.
  • Production-code diff under 400 lines (excluding tests). If exceeded, decompose.
  • PR is independently revertable without breaking main.
  • npm run standard and npm test pass with coverage thresholds met.

Out of Scope

  • Sampler kernel correctness or joint-distribution validation.
  • Changing the ESS truncation rule — measure and document first; any rule change is a separate issue.
  • run-chains and parallel-tempering orchestration behaviour.

Notes

Complements #1224 (single hand-computed gelmanRubin reference) by making the coverage systematic. A disagreement with coda or Stan on ess() is not automatically a bug — the conventions genuinely differ — but the deliverable is knowing which convention is implemented and documenting it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions