---
title: "How MBAR joins windows into one equilibrium distribution"
description: "Derive MBAR from the sampling mixture, calculate target weights in a hand-solvable example and diagnose an unsupported connection."
canonical_url: "https://sandboxphysics.com/stories/free-energy/multistate-reweighting/"
language: "en"
page_type: "story"
alternate_languages:
  zh-CN: "https://sandboxphysics.com/zh/stories/free-energy/multistate-reweighting/"
last_modified: "2026-10-28"
---

[Free energy and rare events](https://sandboxphysics.com/stories/free-energy/)

L3 · Chapter 4

# How MBAR joins windows into one equilibrium distribution

Sandbox Physics · 2026-10-28

Raw counts from different windows cannot simply be added: their preferences and sampling amounts differ. MBAR estimates their relative normalization and assigns a target weight to every saved configuration. It uses each configuration’s energy in every window without first binning the input energies.

## Before you begin

Single-window reweighting from Chapter 3, exponentials, logarithms and weighted averages. The mixture density explains the denominator before the estimating equations appear.

[Review the preceding chapter](https://sandboxphysics.com/stories/free-energy/umbrella-windows/)

- Explain the state counts, sample amounts and free-energy constants in the MBAR denominator.
- Calculate target weights in a finite example and separate solving an equation from adequate sampling.

## Evaluate each saved configuration in every window

Pool $N$ saved configurations $\mathbf r_n$. Window $k$ contributes $N_k$ samples with reduced potential $u_k=\beta(U+w_k)$ and dimensionless free energy $f_k=-\ln Z_k$. A saved configuration can be evaluated under every window’s potential.

The mixture density is proportional to $\sum_k N_k e^{f_k-u_k(\mathbf r)}$. Configurations common in many contributing windows need less target weight. The factors $N_k$ correct for unequal sampling amounts.

Source: Michael R. Shirts and John D. Chodera · Giovanni Bussi

## Find relative heights by self-consistency

If the constants $f_k$ were known, reweighted sums would estimate each partition function. Requiring those estimates to equal the partition functions already used gives the self-consistent equations. Iterate and subtract the first free energy after each update to fix an arbitrary common zero.

At a shared temperature with known biases, these equations can also be written in the binless WHAM form used by the PLUMED tutorial. Evaluate exponential sums in the logarithmic domain to avoid numerical underflow. Convergence means the equations for these samples were solved. Trapped trajectories can also produce a stable solution.

$$
\hat f_i=-\ln\sum_{n=1}^{N}\frac{e^{-u_i(\mathbf r_n)}}{\sum_{k=1}^{K}N_k e^{\hat f_k-u_k(\mathbf r_n)}}
$$

Shirts and Chodera, Eq. (11). A common additive shift changes no meaningful free-energy difference.

Source: Michael R. Shirts and John D. Chodera · Giovanni Bussi

## Convert constants into target weights

For the unbiased target $u_0=\beta U$, first compute unnormalized weight $v_n$ for every saved configuration. Normalize by their sum. A target expectation is the resulting weighted average. The target itself need not have a directly sampled trajectory.

At a shared temperature, with windows differing only by known biases, the common $e^{-\beta U}$ cancels. Bias energies alone then suffice for reweighting. The hidden coordinates still have to be sampled; algebraic cancellation cannot explore them.

$$
v_n=\frac{e^{-u_0(\mathbf r_n)}}{\sum_k N_k e^{\hat f_k-u_k(\mathbf r_n)}},\qquad W_n=\frac{v_n}{\sum_m v_m},\qquad \widehat{\langle A\rangle}_0=\sum_n W_n A(\mathbf r_n)
$$

These are normalized weights for an unsampled target. A plotted free energy additionally requires a density estimate in the specified coordinate.

## A complete example with sixteen configurations

The target has equal-energy left and right configurations. Window A penalizes the right by reduced energy $\ln 3$; B penalizes the left by the same amount. A contributes twelve observations, nine left and three right. B contributes four, one left and three right. Their equal partition functions allow $\hat f_1=\hat f_2=0$.

The mixture denominator is $12+4/3=40/3$ on the left and $12/3+4=8$ on the right. Unnormalized target weights are $3/40$ and $1/8$. Ten left observations sum to three quarters, as do six right observations. Normalization recovers one half on each side. Pooling raw counts instead gives left probability $10/16=0.625$.

Counts were chosen equal to each window’s expected proportions so the calculation fits on paper. Random data will not generally recover one half exactly. Independent repeats and the next chapter assess that error.

Original two-configuration example; energies are in thermal units.

| Configuration | A count | B count | Target weight per observation |
| --- | --- | --- | --- |
| Left | 9 | 1 | $1/20$ |
| Right | 3 | 3 | $1/12$ |

## A final histogram still has its own error

MBAR does not bin input energies. Drawing $F(s)$ still requires a density estimate. A bin of width $\Delta s_j$ and total target weight $P_j$ has density approximately $P_j/\Delta s_j$. Wide bins smear barriers; narrow ones can have no observations. An arbitrary pseudocount cannot turn an unvisited region into a measurement.

Inspect overlap too. Floating-point calculations may retain tiny connections across practically disconnected regions. Those connections do not establish a well-measured relative height. The experiment retains unsupported regions and reports usable coverage.

$$
\hat F_j=-k_{\mathrm B}T\ln\!\left(\frac{\sum_{n:\,s_n\in B_j}W_n}{\Delta s_j}\right)+C
$$

Divide by bin width to estimate density. Unequal-width bins make this distinction essential.

Source: Michael R. Shirts and John D. Chodera · Giovanni Bussi

## Try the reasoning in an experiment

### [Compare three answers from the same records](https://sandboxphysics.com/labs/umbrella-mbar/)

1. Hold windows and seed fixed. Compare pooled counts, MBAR and the independent two-dimensional integral. Identify changes caused by bias.
2. Export trajectories and per-sample target weights. Sum weights in a chosen coordinate interval to reproduce its probability.
3. Change overlap and resample. Explain the distinct questions answered by solver convergence, effective sample size and reference error.

## Exercises and explanations

1. Add seven to all estimated window free energies. Do normalized target weights change?

   Read the explanation

   Every mixture denominator gains the same exponential factor. All unnormalized weights scale together, and normalization cancels it. The arbitrary common free-energy zero has no effect.

2. In the example, sample B twelve times too, retaining its expected proportions. What do pooled counts and reweighting give?

   Read the explanation

   A contributes nine left and three right; B contributes three left and nine right. Both methods yield one half. Unequal sample amounts in the original example break this special symmetry and require the mixture weights.

[Previous: Crossing a barrier with overlapping umbrella windows](https://sandboxphysics.com/stories/free-energy/umbrella-windows/) [Next: Why error bars can miss the largest error](https://sandboxphysics.com/stories/free-energy/uncertainty-and-validation/)

## Sources and reproduced scope

Worked examples and schematic figures are original teaching material. The numerical research slice compares specified estimator equations on our seeded two-coordinate records with independent quadrature and PyMBAR. The final chapter reads Figure 1 of the MBAR paper and states which experimental data remain outside that calculation.

[Model definitions, scripts and numerical records](https://github.com/yangzichao/sandboxphysics/tree/main/docs/frontier/fr15)

1. [Giovanni Bussi, PLUMED Masterclass 21.3, Umbrella sampling (2021; documentation v2.9)](https://www.plumed.org/doc-v2.9/user-doc/html/masterclass-21-3.html)

   Exercises on static restraints, combining windows with binless WHAM, reweighting a different coordinate and uncertainty. Its alanine-dipeptide trajectories are not used here.

2. [Michael R. Shirts and John D. Chodera, Statistically optimal analysis of samples from multiple equilibrium states, J. Chem. Phys. 129, 124105 (2008)](https://arxiv.org/abs/0801.1426v3)

   Frozen arXiv v3: Sections II–IV, Eqs. (9), (11)–(14), Section V and Figure 1, Appendices A–C. We implement the equilibrium estimating equations on our synthetic model. Figure 1 is read as an experimental example; its DNA-hairpin traces and plotted values are not reproduced.
