Skip to content
QFT.org

Search QFT.org

Enter a word or phrase.

    You can also browse the main navigation and chapter contents.

    Partition Functions and Free-Energy Differences

    A normalized Markov chain can estimate an observable without knowing its partition function. That convenience becomes an obstacle when the partition function itself is the quantity of interest. How can we measure the free-energy change when an interaction is turned on?

    We will compute a finite scalar integral in two ways: direct reweighting from a Gaussian and integration along a coupling path. Independent quadrature provides the comparison value. The calculation makes the reference normalization, sampling error and path-discretization error explicit.

    Preparation: Gaussian integrals, importance sampling, and expectations with positive Euclidean weights. Here F=−log⁡ZF=-\log Z is dimensionless; a thermodynamic free energy at temperature TT would include the factor TT in units with kB=1k_B=1.

    Specify the measure before quoting a partition function

    Use four dimensionless real variables, periodic indexing ϕ4=ϕ0\phi_4=\phi_0, and the same Lebesgue measure d4ϕ\mathrm d^4\phi at every coupling. Define

    Sλ(ϕ)=12ϕTKϕ+λV(ϕ),V(ϕ)=14∑i=03ϕi4,ϕTKϕ=∑i=03[(ϕi+1−ϕi)2+ϕi2],Zλ=∫R4d4ϕ e−Sλ(ϕ).\begin{aligned} S_\lambda(\phi)&=\frac12\phi^TK\phi+\lambda V(\phi),\\ V(\phi)&=\frac14\sum_{i=0}^{3}\phi_i^4,\\ \phi^TK\phi&=\sum_{i=0}^{3} \left[(\phi_{i+1}-\phi_i)^2+\phi_i^2\right],\\ Z_\lambda&=\int_{\mathbb R^4}\mathrm d^4\phi\,e^{-S_\lambda(\phi)}. \end{aligned}

    The local quartic normalization is λ/4\lambda/4. It does not redefine the interaction convention of any other article. We turn on λ\lambda from 0 to g=0.5g=0.5.

    The Gaussian matrix has eigenvalues 1,3,3,51,3,3,5, so

    Z0=(2π)245=5.8850950272.Z_0=\frac{(2\pi)^2}{\sqrt{45}} =5.8850950272.

    Changing the constant normalization of the common measure changes every ZλZ_\lambda by that constant but leaves Zg/Z0Z_g/Z_0 invariant. Adding a coupling-dependent constant to the action does change the ratio and must be retained. A tractable proposal density supplies a known reference normalizer; it is not the interacting normalizer.

    Reweight directly from the Gaussian

    Factor the Gaussian integrand out of ZgZ_g:

    ZgZ0=⟨e−gV⟩0,ΔF=Fg−F0=−log⁡⟨e−gV⟩0.\frac{Z_g}{Z_0} =\left\langle e^{-gV}\right\rangle_0, \qquad \Delta F=F_g-F_0 =-\log\left\langle e^{-gV}\right\rangle_0.

    Thus independent ϕ∼N(0,K−1)\phi\sim N(0,K^{-1}) draws give an unbiased estimator of the ratio. Taking its negative logarithm produces a finite-sample biased estimator of ΔF\Delta F. Since −log⁡-\log is convex, its expected bias is nonnegative whenever the needed expectation exists.

    For small relative fluctuations of the sample mean R^\widehat R, expansion about R=Zg/Z0R=Z_g/Z_0 gives

    E[−log⁡R^]−ΔF≃Var⁡(R^)2R2,Var⁡(−log⁡R^)≃Var⁡(R^)R2.\begin{aligned} \mathbb E[-\log\widehat R]-\Delta F &\simeq\frac{\operatorname{Var}(\widehat R)}{2R^2},\\ \operatorname{Var}(-\log\widehat R) &\simeq\frac{\operatorname{Var}(\widehat R)}{R^2}. \end{aligned}

    This expansion requires concentration around nonzero RR; it is not a remedy for poor overlap. Here V≥0V\ge0 and g≥0g\ge0, so the weights lie in (0,1](0,1] and their variance exists. They can still become overwhelmingly tiny when the deformation or number of field variables is large.

    Integrate an expectation along the coupling path

    Differentiating under the integral gives

    dFλdλ=⟨V⟩λ,ΔF=∫0g⟨V⟩λ dλ.\frac{\mathrm dF_\lambda}{\mathrm d\lambda} =\langle V\rangle_\lambda, \qquad \Delta F=\int_0^g\langle V\rangle_\lambda\,\mathrm d\lambda.

    The differentiation is justified for this finite integral: the positive quadratic term and nonnegative quartic coupling dominate the required polynomial moments throughout the interval. If a model's measure or domain depends on λ\lambda, its derivative contributes too.

    Two checks follow immediately:

    Fλ′≥0,Fλ′′=−Var⁡λ(V)≤0.F_\lambda'\ge0, \qquad F_\lambda''=-\operatorname{Var}_\lambda(V)\le0.

    Turning on a positive interaction reduces ZZ and increases FF, but its slope decreases as large fields become suppressed. The initial slope can be computed by Wick's theorem. Since every Gaussian site has variance Cii=7/15C_{ii}=7/15,

    F0′=14∑i3Cii2=4975≃0.6533333.F_0'=\frac14\sum_i3C_{ii}^2 =\frac{49}{75}\simeq0.6533333.

    Concavity therefore bounds 0≤ΔF≤gF0′=49/150≃0.3266670\le\Delta F\le gF_0'=49/150\simeq0.326667. This bound is a useful sign and normalization check before any simulation.

    Choose quadrature nodes λj\lambda_j and positive weights aja_j on [0,g][0,g]. The thermodynamic-integration estimator is

    ΔF^TI=∑jaj⟨V⟩^λj.\widehat{\Delta F}_{\rm TI} =\sum_j a_j\widehat{\langle V\rangle}_{\lambda_j}.

    If estimates at different nodes are independent, its variance is the sum ∑jaj2Var⁡(⟨V⟩^λj)\sum_j a_j^2\operatorname{Var}(\widehat{\langle V\rangle}_{\lambda_j}). Correlated replicas or reused data require cross-covariance terms. Increasing samples reduces sampling variance; increasing path nodes addresses a different error, quadrature bias along λ\lambda.

    A calculation with two independent numerical paths

    Gaussian-coordinate product quadrature evaluates R=⟨e−gV⟩0R=\langle e^{-gV}\rangle_0 directly. Increasing from 32 to 40 Gauss–Hermite nodes per independent Gaussian coordinate changes ΔF\Delta F by 1.2×10−101.2\times10^{-10}. The finer value is

    ΔF=0.229287735449,Zg=4.6792374213.\boxed{\Delta F=0.229287735449}, \qquad Z_g=4.6792374213.

    These are converged numerical comparisons for the specified finite integral, not rigorous error intervals or continuum QFT results.

    A separate path evaluates ⟨V⟩λ\langle V\rangle_\lambda and integrates it with 8- and 16-node Gauss–Legendre rules. Using 32-node field quadrature to evaluate the integrands, their differences from the endpoint result are respectively −1.69×10−9-1.69\times10^{-9} and 1.16×10−101.16\times10^{-10}. This comparison isolates the coupling integration and its residual field-quadrature error before introducing random sampling.

    For the stochastic path, sample the Gaussian and accept with e−λVe^{-\lambda V}. The accepted fields are independent draws from the interacting distribution at that node. Use 2,048 accepted fields per node, and repeat the whole experiment 128 times. Direct exponential averaging instead uses 32,768 independent Gaussian draws per repetition.

    MethodAccepted fields per repetitionAverage estimateStandard deviation across repetitions
    Thermodynamic integration, 8 nodes16,3840.229409550.003086
    Thermodynamic integration, 16 nodes32,7680.229217340.002049
    Direct exponential average32,7680.229239020.001633

    All three repeated-run means agree with quadrature at their measured standard errors. The direct-log mean happens to lie slightly below the exact answer in this finite set of repetitions; this statistical fluctuation does not reverse the nonnegative expectation bias from Jensen's inequality.

    In this mild deformation, direct exponential averaging is more precise than the 16-node path at the same accepted-field count. It also avoids rejection sampling and node setup. The latter path used 5,234,375 Gaussian proposals over 128 repetitions, versus 4,194,304 direct Gaussian fields for the exponential average. Both counts exclude quadrature used for validation. Thermodynamic integration earns its extra work when intermediate ensembles solve an overlap problem; it is not intrinsically superior.

    Bridge distributions and annealed paths

    A bridge can use samples from both endpoint distributions. For actions S0,S1S_0,S_1 on the same measure and a suitable function hh, the identity

    Z1Z0=⟨he−S1⟩0⟨he−S0⟩1\frac{Z_1}{Z_0} =\frac{\langle h e^{-S_1}\rangle_0} {\langle h e^{-S_0}\rangle_1}

    follows because the two numerators before normalization contain the same integral ∫he−S0−S1\int h e^{-S_0-S_1}. Choose hh so the relevant expectations are finite and the important bridge region is sampled by both ensembles. Choices depending on the unknown ratio lead to self-consistent equations. Shirts and Chodera, §III give a multistate version; the umbrella example implements that construction.

    A sequence S0,…,SLS_0,\ldots,S_L also gives the algebraic product

    ZLZ0=∏j=1L⟨e−Sj+Sj−1⟩j−1.\frac{Z_L}{Z_0}=\prod_{j=1}^{L} \left\langle e^{-S_j+S_{j-1}}\right\rangle_{j-1}.

    Each factor uses its stated normalized intermediate ensemble. Neighboring distributions can overlap well even when the endpoints do not. Multiplying independently estimated ratios remains unbiased for the product, but its relative variance accumulates; taking a logarithm adds another finite-sample bias. Shared data require their joint error analysis.

    In annealed importance sampling, one need not equilibrate every intermediate state independently. Start with an exact draw from π0\pi_0, multiply its weight by e−Sj+Sj−1e^{-S_j+S_{j-1}} at each step, and then apply a kernel invariant under πj\pi_j. Reweighting converts the current weighted measure to e−Sj/Z0e^{-S_j}/Z_0; invariance preserves it through the transition. Induction shows that the expected final weight is ZL/Z0Z_L/Z_0. This argument assumes the initial distribution and transition invariance are correct and the necessary support is present; see Neal, §2. A finite sample of weights can still miss the trajectories carrying most of their expectation.

    The numerical table above tests direct reweighting and thermodynamic integration only. It does not report an unperformed bridge or annealed-sampling benchmark.

    Summary

    Compute a partition ratio relative to a specified measure and known reference. Direct exponential averaging, thermodynamic integration and bridge or annealed paths express the same ratio through different sampled quantities. Their errors depend on overlap, normalization, nonlinear transformations and the cost of intermediate ensembles. Independent finite-integral checks make those distinctions visible before applying them to a large field system.

    Exercises

    Change only the Gaussian mass

    Let Sa=ϕTKaϕ/2S_a=\phi^TK_a\phi/2 and Sb=ϕTKbϕ/2S_b=\phi^TK_b\phi/2, with positive matrices of the same dimension and the same integration measure. Find Fb−FaF_b-F_a and its derivative along a smooth positive-matrix path K(t)K(t).

    Solution

    Gaussian integration gives

    Fb−Fa=12log⁡det⁡Kbdet⁡Ka.F_b-F_a=\frac12\log\frac{\det K_b}{\det K_a}.

    Differentiating gives F′=12tr⁡(K−1K′)F'=\tfrac12\operatorname{tr}(K^{-1}K'). The expectation of ∂tS=ϕTK′ϕ/2\partial_tS=\phi^TK'\phi/2 is the same, since ⟨ϕiϕj⟩=(K−1)ij\langle\phi_i\phi_j\rangle=(K^{-1})_{ij}.

    An additive constant changes the free energy

    Replace SλS_\lambda by Sλ+aλS_\lambda+a\lambda. Does the normalized field distribution change? How must both estimators of ΔF\Delta F change?

    Solution

    The normalized distribution is unchanged because the factor e−aλe^{-a\lambda} cancels. But ZλZ_\lambda becomes e−aλZλe^{-a\lambda}Z_\lambda, so ΔF\Delta F increases by agag. Direct reweighting gains the factor e−age^{-ag} inside its ratio, and the thermodynamic integrand becomes ⟨V⟩λ+a\langle V\rangle_\lambda+a. Omitting an action constant is harmless for normalized field averages but not for an absolute free-energy difference.

    References

    • R. M. Neal, “Annealed importance sampling,” arXiv:physics/9803008, §2.
    • M. R. Shirts and J. D. Chodera, “Statistically optimal analysis of samples from multiple equilibrium states,” Journal of Chemical Physics 129, 124105 (2008), arXiv:0801.1426, §III, doi:10.1063/1.2978177.

    Reproducible calculations: examples/computational-qft/monte-carlo-methods/README.md.

    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.