Skip to content

Exclude lag-0 autocorrelation from effective sample size denominator - #1753

Closed
davrens101 wants to merge 1 commit into
pints-team:mainfrom
davrens101:fix-ess-lag0-indexing
Closed

davrens101 wants to merge 1 commit into
pints-team:mainfrom
davrens101:fix-ess-lag0-indexing

Conversation

@davrens101

Copy link
Copy Markdown

Summary

Fixes #1751.

In effective_sample_size_single_parameter in pints/_diagnostics.py, the integrated autocorrelation time was computed as:

ess = n / (1 + 2 * np.sum(rho[0:T]))

Since rho[0] == 1.0 (lag 0 autocorrelation), rho[0] was included in np.sum(rho[0:T]), making the denominator 1 + 2*(1 + sum_{k>=1} rho[k]) = 3 + 2 * sum_{k>=1} rho[k]. For IID / uncorrelated samples, this returned n / 3 instead of n.

Changes

  • Changed np.sum(rho[0:T]) to np.sum(rho[1:T]) so lag 0 is not double counted.
  • Updated precomputed test values in pints/tests/test_diagnostics.py.
  • Added an explicit test for IID normal draws checking that ESS ≈ n.

Signed-off-by: Davis Rens <166565828+davrens101@users.noreply.github.com>
@davrens101

Copy link
Copy Markdown
Author

Closing to tidy up my open PRs. Happy to reopen if this is still useful.

@davrens101 davrens101 closed this Dec 4, 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.

`effective_sample_size' includes the lag-0 autocorrelation in the denominator, giving ESS ≈ n/3 for independent samples

1 participant