- Home
- Library
- Computational Quantum Field Theory
- Sampling Measures and Estimating Free Energies
- Autocorrelation and Effective Sample Size
Autocorrelation and Effective Sample Size
A simulation stores 8,192 field configurations. Does that mean an observable has 8,192 independent measurements? Usually it does not: nearby configurations share fluctuations. The uncertainty of their average depends on both the update rule and the observable being measured.
We derive that uncertainty, test it on an exactly soluble process, and repeat the test for a finite scalar-field correlator. The examples also show why discarding measurements or stopping an autocorrelation sum early can give misleading error bars.
Preparation: Expectation values, covariance, and Gaussian random variables. Monte Carlo time below counts algorithmic updates; it is unrelated to physical time.
Count pairs in the sample mean
Let be a real stationary measurement history with mean and nonzero finite variance. Stationarity means that its covariance depends only on the separation:
For , expand the square of the sum. There are diagonal pairs and ordered pairs at positive separation . Therefore, exactly at finite ,
If the correlations are absolutely summable and the run is long compared with their decay, define
compares the variance of this mean with that of independent draws having the same one-measurement variance. It is specific to , not a property of a configuration file alone. Independent samples have in this convention; some authors instead call the autocorrelation time.
These variance identities do not by themselves establish a central limit theorem or convergence from a nonequilibrium start. A normal confidence interval additionally requires an appropriate limit theorem and a sufficiently long run. A chain trapped in a sector can have a deceptively short measured correlation time.
An exact test: the autoregressive process
Choose and independent standard normal variables . Start with and update
The variance remains one, and repeated substitution gives . Summing the geometric series yields
At , and the asymptotic effective sample size is . An independent-sample standard error is too small by a factor of three. At , however, and : alternating correlations improve the mean. This does not create new independent configurations; it improves this particular estimator.
Starting with the exact stationary distribution deliberately removes equilibration bias from this test. Starting instead at a fixed gives . That transient must be addressed separately before applying stationary error formulas.
Estimate the correlation sum without summing noise
For one stored history, a direct estimate is
Subtracting the estimated mean introduces finite-run bias. Correlations at large lag also become noisy because fewer pairs contribute. Instead of summing every lag, choose a window and estimate
A short window misses a positive tail; a very long window adds noise and can even yield an inadmissible negative variance estimate. Such an estimate is a failure of this error analysis, not a zero-error result. Compare windows, longer runs, and independent streams. The -method develops systematic window selection and the uncertainty of the error estimate itself [1, §§3.1–3.3]. Our benchmark uses fixed windows so that this tradeoff can be seen directly; it is not an implementation of that paper's automatic window procedure.
A small slow component is especially easy to miss. Take two independent unit-variance autoregressive processes with coefficients and , and combine them with amplitudes and . The resulting unit-variance process has
Even the exact correlation function truncated at gives only . This is a truncation error, before any statistical noise is added. The following analytic plot shows the missing contribution accumulating over hundreds of updates.
Blocking and independent runs
Partition a stationary stream into consecutive blocks of measurements, so , and denote their averages by . If the block averages are approximately independent, estimate
Increase until the error estimate becomes stable while retaining enough blocks to estimate its uncertainty. Very short blocks retain correlations; very long blocks leave too few observations. Normal intervals with an estimated variance can under-cover when is small. Blocking is a useful comparison, not a proof that an unseen slow mode is absent [1, Appendix B].
For several genuinely independent runs, do not form lag pairs across their boundaries. Compare the run means as well as their within-run fluctuations. Keeping rejected proposals as repeated configurations is essential: deleting them changes the sampled history and generally its distribution.
For a nonlinear quantity , the leading fluctuating direction is . Its autocorrelation can differ from every individual component's. Resample whole aligned blocks and repeat the nonlinear calculation inside each resample; independently resampling correlated numerator and denominator measurements destroys information needed for a ratio's error.
A finite scalar-field correlator
Consider eight real scalar variables with periodic labels and dimensionless Euclidean action
The lattice spacing and mass in lattice units are both one. This is a fixed Gaussian target, not a continuum extrapolation. Its covariance is , which can also be calculated by the discrete Fourier sum
Generate independent and use
The new covariance is , so the chain is stationary. Moreover . This exact global Gaussian update is chosen to test error estimation; it is not an efficient general-purpose algorithm for interacting fields.
Measure . Its mean is . Gaussian factorization gives three pairings in . The same-time pairing is and cancels when we subtract the mean squared. The two cross-time pairings leave
At the field component has , while this correlator has . Analyze the measured observable rather than assigning every measurement the field's correlation time.
Reproduce the coverage experiment
The example examples/computational-qft/autocorrelation/check.py runs 1,024 independent stationary histories using NumPy's random generator with seed 20261021. It checks the covariance against both matrix inversion and Fourier modes, then compares the spread of run means with the exact finite- pair sum. Run it from the repository root with Python 3, NumPy, and Matplotlib:
python3 examples/computational-qft/autocorrelation/check.py
For each history it constructs the interval . Coverage is the fraction of these intervals containing the exact mean. The retained run gives:
| Quantity | Samples per run | Treating draws as independent | Using exact finite- variance | Estimated covariance, |
|---|---|---|---|---|
| AR(1), | 2,048 | 46.5% | 93.8% | 93.2% |
| AR(1), | 8,192 | 49.1% | 95.1% | 94.6% |
| Scalar | 2,048 | 65.6% | 94.5% | 93.6% |
| Scalar | 8,192 | 66.1% | 95.5% | 95.9% |
At 95% coverage the sampling uncertainty of a fraction estimated from 1,024 runs is about 0.68 percentage points. The experiments at the two lengths use prefixes of the same histories and are consequently correlated. The exact-variance interval is exactly Gaussian for the AR mean; for the bilinear field observable its normal form is a long-run approximation.
The saved output also compares and block lengths . At , produced four nonpositive variance estimates for the AR process and one for the field correlator. They are reported as invalid intervals and count as coverage failures, not silently clipped or discarded. Longer histories reduce these problems. These tests isolate stationary sampling errors; they say nothing about equilibration, multimodal exploration, or the interacting continuum limit.
Thinning changes the estimator
Retaining every th AR measurement changes its autocorrelation to , so
at fixed total number of updates and long run length. With and , the time in stored-sample units is ; converting that time to update units gives , not the unthinned value . The effective sample size is about 94.24% of the unthinned value. Multiplying a measured time by the storage interval converts units; it does not recover the autocorrelation sum of the discarded history. Thinning can save storage or expensive measurement work, but that is a separate cost comparison.
Markov-chain ESS also differs from the common importance-weight diagnostic . Equal weights make that diagnostic even when successive observations are strongly correlated. Neither diagnostic alone establishes overlap with an unvisited sector.
For a correlator, keep the whole vector of Euclidean separations together when blocking Monte Carlo updates. Even independent field configurations contribute correlated estimates at different separations. The periodic scalar mass calculation gives downloadable means and their full covariance, then compares the mass obtained with full and diagonal weights.
Compare the exactly known slow tail above with the measured Ising energy and squared-magnetization histories. The local and cluster chains use different amounts of work per update, so their lag cutoffs and their estimated errors must be compared in common units.
Summary
Derive the uncertainty of a mean from the covariance of its actual observable. State the update unit and autocorrelation convention, retain rejected states, examine the lag window and block size, and use exact examples and independent runs to test the reported intervals. An apparently large effective sample size cannot establish that the chain reached the intended distribution.
Exercises
1. Check a nonlinear observable. For stationary AR(1) with unit variance, find the autocorrelation time of and compare it with that of at .
Solution
Gaussian factorization gives , hence and . At this is , while . Negative correlations help the mean of , but squaring removes the alternating sign and gives positively correlated measurements.
2. Quantify the hidden tail. What fraction of the asymptotic mean variance is retained by an exact truncation in the two-mode example?
Solution
At fixed and one-measurement variance, the asymptotic mean variance is proportional to . The ratio is . Thus the variance estimate misses about 54.4%, and its standard error is only of the correct value. More accurately measuring the first ten lags cannot repair the omitted tail.
References
- U. Wolff, “Monte Carlo errors with less errors,” Computer Physics Communications 156 (2004), 143–153, corrected arXiv version 4 (2006). Full text. Sections 2–3 discuss correlated observables and covariance-sum error estimates; Appendix B compares binning.
Scrollable formula. Use Left and Right arrow keys to reveal hidden content.
Scrollable table. Use Left and Right arrow keys to reveal hidden columns.
Scrollable figure. Use Left and Right arrow keys to reveal hidden content.