Skip to content
QFT.org

Search QFT.org

Enter a word or phrase.

    You can also browse the main navigation and chapter contents.

    Metropolis, Heat-Bath, and Overrelaxation Updates

    A scalar-field simulation changes one number at a time, but its output is an ensemble of entire fields. A good local update must preserve the desired joint distribution and move through it efficiently. Accepting nearly every proposal answers neither question by itself: arbitrarily small changes have excellent acceptance and poor decorrelation.

    Preparation: the finite scalar action and its first Metropolis simulation. All fields and couplings below are dimensionless lattice quantities. We compare algorithms for a fixed finite lattice; the Markov update number is not Euclidean or physical time.

    One conditional distribution determines the update

    On a periodic two-dimensional lattice, take

    S(φ)=∑n[12∑μ=12(φn+μ^−φn)2+m22φn2+λ24φn4].S(\varphi)=\sum_n\left[\frac12\sum_{\mu=1}^2(\varphi_{n+\hat\mu}-\varphi_n)^2 +\frac{m^2}{2}\varphi_n^2+\frac{\lambda}{24}\varphi_n^4\right].

    Here m2m^2 is the dimensionless bare mass squared, not a measured gap. Our calculation uses m2=1m^2=1, λ=0\lambda=0 or 22, and an 8×88\times8 lattice. More generally the following Gaussian proposal needs A=4+m2>0A=4+m^2>0, and the full target must be normalizable. For example m2>0m^2>0, λ≥0\lambda\geq0 suffices.

    Hold every field except z=φnz=\varphi_n fixed, and define its neighbor sum

    hn=∑μ=12(φn+μ^+φn−μ^),A=4+m2.h_n=\sum_{\mu=1}^2(\varphi_{n+\hat\mu}+\varphi_{n-\hat\mu}),\qquad A=4+m^2.

    Collecting the four adjacent bonds gives the conditional density, with respect to dz\mathrm dz,

    p(z∣φ≠n)=1Znexp⁡[−A2z2+hnz−λ24z4].p(z\mid\varphi_{\ne n})=\frac1{Z_n} \exp\left[-\frac A2z^2+h_nz-\frac\lambda{24}z^4\right].

    Thus for z′=z+δz'=z+\delta the complete action change is local:

    ΔS=A(zδ+δ22)−hnδ+λ24[(z+δ)4−z4].\Delta S=A\left(z\delta+\frac{\delta^2}{2}\right)-h_n\delta +\frac\lambda{24}\left[(z+\delta)^4-z^4\right].

    Both forward and backward bonds contribute to AA. Counting only the bonds written with origin nn would give the wrong diagonal coefficient. On a periodic extent of two, the same neighboring site occurs twice, corresponding to the two distinct terms in the action.

    Metropolis acceptance and the role of rejected moves

    For a general proposal density q(z′∣z)q(z'\mid z), accept with probability

    α(z,z′)=min⁡(1,p(z′∣φ≠n)q(z∣z′)p(z∣φ≠n)q(z′∣z)).\alpha(z,z')=\min\left(1, \frac{p(z'\mid\varphi_{\ne n})q(z\mid z')} {p(z\mid\varphi_{\ne n})q(z'\mid z)}\right).

    The accepted probability flux in either direction is the smaller of p(z)q(z′∣z)p(z)q(z'\mid z) and p(z′)q(z∣z′)p(z')q(z\mid z'). This proves conditional detailed balance. Integration over the fixed neighbors proves invariance of the full e−Se^{-S} measure. The proposal ratio cannot be omitted just because only one field changes.

    Our random-walk proposal is z′=z+uz'=z+u with uu uniform on [−1,1][-1,1]. It is symmetric, so α=min⁡(1,e−ΔS)\alpha=\min(1,e^{-\Delta S}). A rejection records the old configuration as the next sample. Recording accepted configurations alone changes the relative residence times and generally biases the measure. The symmetric-proposal construction and composition of invariant steps are discussed in Kennedy, §§2.5–2.6, printed pp. 9–10, PDF.

    We update all even sites and then all odd sites, where parity is (n1+n2) mod 2(n_1+n_2)\bmod2. On an even periodic lattice, no bond connects sites in the same half-sweep. Their conditionals therefore factorize while the opposite parity is fixed. Neighbor sums must be recomputed between half-sweeps. An odd periodic extent has a wrapping bond between equal parities; this parallel update would then be invalid.

    Each half-sweep preserves the target. Their ordered product also preserves it, although the full even-then-odd sweep need not satisfy detailed balance: its reverse has the opposite order. Invariance, convergence from an initial state, and the rate of decorrelation are different properties. With a positive normalizable density and nonzero-width random proposals, repeated local moves can reach every open region; finite warmup and finite sampling errors still require diagnostics.

    Gaussian heat bath and its interacting correction

    At λ=0\lambda=0, complete the square:

    A2z2−hnz=A2(z−μn)2−hn22A,μn=hnA.\frac A2z^2-h_nz=\frac A2(z-\mu_n)^2-\frac{h_n^2}{2A},\qquad \mu_n=\frac{h_n}{A}.

    Drawing

    z′=μn+ηA,η∼N(0,1),z'=\mu_n+\frac{\eta}{\sqrt A},\qquad \eta\sim N(0,1),

    is an exact conditional heat bath. Conditional on the neighbors it forgets zz entirely. Successive whole fields remain correlated because their neighbors evolve through the same chain. “Heat bath” does not mean an independent draw from the full field distribution.

    For λ>0\lambda>0, use the same Gaussian as an independent proposal q(z′)q(z'). Its quadratic exponent cancels the quadratic part of the target in the Hastings ratio:

    p(z′)q(z)p(z)q(z′)=exp⁡[−λ24(z′4−z4)],α=min⁡(1,e−λ(z′4−z4)/24).\frac{p(z')q(z)}{p(z)q(z')}= \exp\left[-\frac\lambda{24}(z'^4-z^4)\right],\qquad \alpha=\min\left(1,e^{-\lambda(z'^4-z^4)/24}\right).

    This is a Gaussian-proposal Metropolis update, not an exact interacting heat bath. The full interacting conditional could instead be sampled by a valid rejection sampler or another exact conditional method. Simply omitting the displayed correction returns the free Gaussian conditional and the wrong theory.

    Overrelaxation moves along a conditional contour

    Reflect about the Gaussian conditional mean:

    z′=2μn−z.z'=2\mu_n-z.

    The transformation is an involution with absolute Jacobian one, and (z′−μn)2=(z−μn)2(z'-\mu_n)^2=(z-\mu_n)^2. It therefore preserves the free conditional density without rejection. At λ>0\lambda>0 it becomes a deterministic proposal with the same quartic acceptance factor as above. Its reverse uses the same fixed neighbors.

    The free reflection conserves the full action at each update. An entire deterministic sequence remains on its initial action surface, so it cannot by itself sample the canonical distribution of action values. It may nevertheless move collective disturbances more effectively when interleaved with an ergodic stochastic update. Since each constituent preserves the target, any fixed sequence or field-independent random mixture does too. A field-dependent decision to apply different kernels needs its own balance argument. Our measured comparison below uses the two stochastic local methods; it does not assign an empirical speedup to overrelaxation without running that comparison.

    For a forward U(1) link Vℓ=eiθℓV_\ell=e^{i\theta_\ell}, use the chapter's endpoint convention Vμ(x)↦G(x+μ^)Vμ(x)G†(x)V_\mu(x)\mapsto G(x+\hat\mu)V_\mu(x)G^\dagger(x). Write the adjacent plaquette angles as

    θp=spℓθℓ+cp,spℓ=±1.\theta_p=s_{p\ell}\theta_\ell+c_p,\qquad s_{p\ell}=\pm1.

    The Wilson action contributes

    Sℓ=−β∑p∋ℓcos⁡(spℓθℓ+cp)+constant=−βRe⁡(eiθℓKℓ)+constant,Kℓ=∑p∋ℓeispℓcp.S_\ell=-\beta\sum_{p\ni\ell}\cos(s_{p\ell}\theta_\ell+c_p)+\text{constant} =-\beta\operatorname{Re}(e^{i\theta_\ell}K_\ell)+\text{constant},\qquad K_\ell=\sum_{p\ni\ell}e^{is_{p\ell}c_p}.

    This definition fixes the staple phase without relying on a backward-link convention. Put Kℓ=∣Kℓ∣eiκℓK_\ell=|K_\ell|e^{i\kappa_\ell} and bℓ=β∣Kℓ∣b_\ell=\beta|K_\ell|. Relative to normalized Haar measure dθ/(2π)\mathrm d\theta/(2\pi), the conditional weight is

    ebℓcos⁡(θ+κℓ)I0(bℓ).\frac{e^{b_\ell\cos(\theta+\kappa_\ell)}}{I_0(b_\ell)}.

    Relative to ordinary dθ\mathrm d\theta, the density has an additional 1/(2π)1/(2\pi). A von Mises draw centered at −κℓ-\kappa_\ell with concentration bℓb_\ell is the heat bath. If Kℓ=0K_\ell=0, the conditional is uniform and its phase is immaterial. A symmetric angular Metropolis proposal instead accepts using the local cosine-action difference. Angles wrap modulo 2π2\pi; the measure is not an unconstrained Cartesian measure on the complex link.

    The distinction becomes especially visible for SU(2). Writing U=u01+iu⋅σU=u_0\mathbf1+i\mathbf u\cdot\boldsymbol\sigma with u02+∣u∣2=1u_0^2+|\mathbf u|^2=1, the Haar marginal of u0u_0 is (2/π)1−u02 du0(2/\pi)\sqrt{1-u_0^2}\,\mathrm du_0. Even a conditional action proportional to −u0-u_0 therefore does not give a flat-measure exponential on [−1,1][-1,1]. The Haar integration calculation supplies this normalization.

    A one-square comparison with an exact answer

    Take four independent Haar links on one open square, with plaquette angle θp=θ0+θ1−θ2−θ3\theta_p=\theta_0+\theta_1-\theta_2-\theta_3. There is no periodic constraint. Integrating three link combinations leaves

    ⟨cos⁡θp⟩=I1(β)I0(β),⟨sin⁡θp⟩=0.\langle\cos\theta_p\rangle=\frac{I_1(\beta)}{I_0(\beta)},\qquad \langle\sin\theta_p\rangle=0.

    The retained link_updates.py actually updates all four links sequentially. At β=4\beta=4, it compares angular Metropolis half-width one with the conditional von Mises heat bath, using 16 random streams, 1024 discarded sweeps and 8192 retained sweeps. Half start at plaquette zero and half at π\pi. Both methods receive 16×8192×4=52428816\times8192\times4=524288 retained link-update calls.

    UpdateAcceptanceMean cos⁡θp\cos\theta_pReplica standard error
    Angular Metropolis0.644940.8635380.000724
    Conditional heat bath10.8631340.000600
    Exact Haar integral—0.863523—

    Errors are the scatter of the 16 independent stream means divided by four; they include within-stream correlations rather than treating all stored fields as independent. Blocking at 16, 64 and 256 sweeps and the two start groups are retained as additional diagnostics. A heat-bath link update makes this particular plaquette independent of its previous angle, so the exact model explains its decorrelation. On a larger lattice, one link participates in several plaquettes and does not independently refresh them all.

    A link-call count is a useful declared work proxy, not equal processor cost. The von Mises generator itself uses rejection sampling; the program counts distribution calls and reports measured kernel time, rather than claiming knowledge of its internal random-draw count. The observed error reduction is modest and noisy at 16 replicas. It is a controlled one-square comparison, not a performance claim for non-Abelian gauge theory.

    Compare scalar errors at equal work

    The shared run_scalar.py compares random-walk and Gaussian-proposal sweeps with HMC. For each action and algorithm it uses 16 separately seeded PCG64 streams, half starting at zero and half at constant +3+3. The local runs discard 2048 sweeps and keep 8192. Seeds and settings were fixed before production. Every observable record, including warmup and repeated rejected fields, is saved once for the chapter's common analysis.

    Define the field average and axis-averaged correlator by

    M=1V∑nφn,Cr=12V∑n∑μ=12φnφn+rμ^.M=\frac1V\sum_n\varphi_n,\qquad C_r=\frac1{2V}\sum_n\sum_{\mu=1}^2\varphi_n\varphi_{n+r\hat\mu}.

    These CrC_r average source positions and axes; they are not the spatially projected correlators also retained for the later fit. At λ=0\lambda=0, the exact mode sum gives ⟨C0⟩=0.254173998\langle C_0\rangle=0.254173998, ⟨C1⟩=0.067717497\langle C_1\rangle=0.067717497 and ⟨M2⟩=1/(Vm2)=0.015625\langle M^2\rangle=1/(Vm^2)=0.015625.

    For each observable, first average within each retained stream, obtaining Oˉr\bar O_r, and then average the R=16R=16 stream means. The reported standard error is

    SE^(Oˉ)=[1R(R−1)∑r=1R(Oˉr−Oˉ)2]1/2.\widehat{\mathrm{SE}}(\bar O)= \left[\frac1{R(R-1)}\sum_{r=1}^R(\bar O_r-\bar O)^2\right]^{1/2}.

    Independence is between streams, not successive fields within one stream. This estimator incorporates each stream's autocorrelation through the variance of its mean, but only 16 stream means make the error estimate itself noisy. It also cannot remove a common initialization bias. The two starting groups, fixed prefixes and the window/block analysis supply additional diagnostics.

    λ\lambdaUpdateAcceptance⟨C0⟩\langle C_0\rangle⟨M2⟩\langle M^2\rangle
    0Random walk0.595300.253784±0.0004370.253784\pm0.0004370.015803±0.0002830.015803\pm0.000283
    0Gaussian heat bath10.254096±0.0002420.254096\pm0.0002420.015677±0.0000600.015677\pm0.000060
    2Random walk0.590020.235718±0.0002620.235718\pm0.0002620.012679±0.0002070.012679\pm0.000207
    2Gaussian proposal + MH0.988140.235464±0.0001350.235464\pm0.0001350.012725±0.0000760.012725\pm0.000076

    Both local kernels perform one conditional/proposal evaluation per site, so each receives 8192V=5242888192V=524288 retained site evaluations per stream. The implementation also recomputes all neighbor sums twice per sweep; those counts, normal/uniform distribution draws and elapsed kernel times are recorded separately. Measurements and their cost are kept separate from the update timings.

    Ratios of estimated scalar standard errors to random-walk errors at equal site-kernel work, for C0, C1, mean field and squared mean field in the free and interacting models.

    At the same target budget of 524288 site-kernel evaluations per stream, the conditional Gaussian proposal gives smaller estimated errors for these four observables. HMC counts its actual gradient and action evaluations, so it contributes fewer stored trajectories at this budget. Each ratio uses errors estimated from 16 independent stream means; uncertainty in the error estimates is not shown. Lines connect discrete observables only as a reading aid. Parameters are 8×88\times8, m2=1m^2=1, and the indicated λ\lambda; this is a finite massive model, not a critical-scaling comparison.

    HMC is included in the figure with its actual force/action work; its acceptance near 0.974 does not make it the best sampler here. The chosen Gaussian conditional is unusually well matched to this weak quartic perturbation. At fixed work its estimated C0C_0 error is about one half of the random-walk error, while the gain for M2M^2 is different. On this implementation the measured kernel-time comparison gives the same preference for the Gaussian proposal on these observables. Neither ranking is a universal statement about interacting theories or optimized implementations.

    As normalization checks, free runs reproduce the finite-lattice covariance, ⟨S⟩/V=1/2\langle S\rangle/V=1/2 and the exact Gaussian moments. For both actions, integration by parts gives the Ward identity

    ⟨1V∑nφn∂S∂φn⟩=1.\left\langle\frac1V\sum_n\varphi_n\frac{\partial S}{\partial\varphi_n}\right\rangle=1.

    The boundary term vanishes for this confining finite-dimensional action. All six main runs agree with their applicable exact means or identities within 1.64 reported standard errors, and their largest start-group difference is 2.40 combined standard errors. These are observed diagnostics, not guaranteed coverage or an equilibration theorem. In particular, a separate fixed-length HMC study exposes a warmup failure despite high acceptance.

    What to carry forward

    Derive an update from its conditional distribution, including the proposal ratio and base measure. Preserve rejections, distinguish an invariant sweep from a reversible sweep, and measure the error of the observable of interest at a stated cost. Hybrid Monte Carlo changes the whole field using fictitious dynamics; the error-analysis article uses these same retained scalar histories to examine autocorrelation windows, blocking and correlated fits.

    Exercises

    The bias from dropping the quartic correction

    At a site whose neighbors sum to zero, assume λ/A2≪1\lambda/A^2\ll1. Derive the first correction to the conditional variance ⟨z2⟩\langle z^2\rangle under exp⁡(−Az2/2−λz4/24)\exp(-Az^2/2-\lambda z^4/24). Compare with the uncorrected Gaussian proposal.

    Solution

    Expand both numerator and normalization about the centered Gaussian:

    ⟨z2⟩=⟨z2⟩0−λ24(⟨z6⟩0−⟨z2⟩0⟨z4⟩0)+O(λ2/A5).\langle z^2\rangle=\langle z^2\rangle_0- \frac\lambda{24}\left(\langle z^6\rangle_0- \langle z^2\rangle_0\langle z^4\rangle_0\right)+O(\lambda^2/A^5).

    The moments are 1/A1/A, 3/A23/A^2 and 15/A315/A^3. Consequently

    ⟨z2⟩=1A−λ2A3+O(λ2/A5).\langle z^2\rangle=\frac1A-\frac\lambda{2A^3}+O(\lambda^2/A^5).

    The positive quartic interaction suppresses large fields. An always-accepted Gaussian draw gives 1/A1/A and misses this first correction. This is a conditional calculation at fixed neighbors; it is not the full interacting lattice variance, whose neighbor distribution also changes.

    A compact reflection and its limitation

    For a nonzero fixed U(1) staple K=∣K∣eiκK=|K|e^{i\kappa}, show that θ′=−θ−2κ\theta'=-\theta-2\kappa modulo 2π2\pi is an invariant deterministic local update. Explain why a lattice sweep made only of these reflections need not sample the canonical ensemble, and how to combine them with a heat bath without changing the target.

    Solution

    The shifted angle changes sign: θ′+κ=−(θ+κ)\theta'+\kappa=-(\theta+\kappa). Thus the local action −β∣K∣cos⁡(θ+κ)-\beta|K|\cos(\theta+\kappa) is unchanged. Reflection is its own inverse and preserves circle Haar measure, establishing invariance for fixed neighboring links. Since all remaining action terms are unaffected, each link reflection conserves the complete Wilson action. A deterministic sweep therefore cannot generate the canonical distribution of action values from a field with one fixed action. This is an explicit obstruction to ergodicity, even if some observables vary along the orbit.

    Insert, for example, one full conditional heat-bath sweep after a fixed number of reflection sweeps. Each factor preserves the same measure, so the composition is invariant. This establishes the target distribution; the improved or worsened error per unit work must still be measured. The number of reflection sweeps should not be chosen as an arbitrary function of the current field without rechecking invariance.

    References

    • A. D. Kennedy, Algorithms for Dynamical Fermions, lectures revised in 2012, arXiv:hep-lat/0607038v2, §§2.5–2.6 and 2.8.2. Detailed balance, composition, and autocorrelation variance; the scalar and compact-link calculations above are worked specializations.

    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.