Solution (source code)

= Solution

The <microcanonical ensemble> describes an isolated system at fixed energy $E$, volume $V$, and particle number $N$, assigning equal weight to accessible states in a narrow energy shell.

The <canonical ensemble> describes a system that can exchange energy with a heat reservoir at fixed temperature $T$, while $V$ and $N$ remain fixed. A microstate $s$ has probability
$$
p_s=\frac{e^{-\beta E_s}}{Z},
\qquad
Z=\sum_s e^{-\beta E_s},
\qquad
\beta=\frac1{k_BT}.
$$

The <grand canonical ensemble> allows exchange of both energy and particles at fixed $T$, $V$, and <chemical potential> $\mu$. Its state weights are
$$
p_s=\frac{e^{-\beta(E_s-\mu N_s)}}{\Xi}.
$$

The choice is irrelevant for bulk thermodynamic observables in the thermodynamic limit when the system is additive, has sufficiently short-range interactions, and lies away from singular phase-coexistence regimes. Then relative energy and particle-number fluctuations vanish as the system size grows. These are the standard conditions for <equivalence of statistical ensembles>.