- Home
- Learn
- Start Here
- Study Paths
- Convergence of a Gaussian Integral
Convergence of a Gaussian Integral
A Gaussian variance computed on successively finer meshes settles at 0.97334. How many of those digits describe the original Gaussian? Compare the calculation against two exact answers, one for the integration window and one for the whole line. They isolate errors a mesh-refinement test alone cannot see.
Preparation. A definite integral, a weighted mean and a short Python loop suffice. The Gaussian integral with a source gives an analytic calculation of the variance.
A numerical expectation with an exact baseline
For a dimensionless variable with action , define
To verify the last equality, take the derivative of . It gives , whose integral vanishes by the endpoint values. The unit variance supplies the full-line benchmark.
Restrict the integration to and divide it into equal intervals of width . At the midpoints
approximate the ratio by
The factor cancels between numerator and denominator. This Python program varies the window and the mesh independently.
from math import exp, fsum
def variance(L, N):
h = 2 * L / N
x = [-L + (j + 0.5) * h for j in range(N)]
w = [exp(-y * y / 2) for y in x]
return fsum(y * y * z for y, z in zip(x, w)) / fsum(w)
for L, counts in [(3, (32, 64, 128)), (4, (128,)),
(5, (128,)), (6, (128, 256))]:
for N in counts:
print(L, N, f"{variance(L, N):.12f}")
The midpoint nodes are deterministic. Repeating the calculation with the same nodes gives the same answer.
First refine the mesh, then enlarge the domain
Integrating by parts on the finite interval retains the endpoint term.
For , this is . Here is the mesh error relative to that finite-window value.
| Mesh error | ||
|---|---|---|
| 32 | 0.973572048746 | |
| 64 | 0.973395754799 | |
| 128 | 0.973351635213 |
Here mesh error means . Doubling reduces it by about four, consistent with the midpoint rule's second-order error for a smooth integrand on a fixed interval.
Even exact integration over this window underestimates the full variance by about . Keep and enlarge the window.
| 4 | 0.998931553854 |
| 5 | 0.999985215715 |
| 6 | 0.999999927964 |
Changing also changes , so check the final mesh again. At , doubling to 256 gives . The finite-window limit is . The remaining discrepancy from one comes mainly from the omitted tail.
A misleading plateau
A calculation at reports and barely changes when the mesh is refined. Is it accurate to four decimal places for the full Gaussian variance? State the next check and the direction in which the missing tail changes the answer.
Solution
No. It accurately approximates a different, truncated distribution. The target variance is one. The removed region has , so restoring it increases the normalized second moment. Enlarge and independently recheck the mesh at that new window. The finite-window integration-by-parts formula predicts both the sign and size of the tail bias.
From quadrature to a lattice observable
Translate the window test to a narrow peak with density on . Here is times the standard deviation of the full Gaussian. Setting restores our weight . If the peak is well inside the interval, increasing the window does little when the initial nodes miss the peak entirely. Compare the estimated integral and its own error indicator before and after resolving the peak. A narrow Gaussian missed by adaptive quadrature.
For many field variables, direct quadrature becomes expensive. Importance sampling replaces the two integrals by a ratio of sample averages. When a Markov chain generates those samples, measure the autocorrelation of the observable to estimate the uncertainty of its mean. The lattice spacing and volume still have to be varied separately.
With a correlated fit and an error estimate in hand, extract a lattice energy from an interacting scalar correlator. For a variational calculation, compare the neural spin-state energy with the independently diagonalized Hamiltonian.
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.