Why the grand canonical ensemble
In the canonical ensemble the total particle number N is fixed, which entangles the levels: filling one leaves fewer particles for the others, and the sums become a nightmare. The trick is to switch to the grand canonical ensemble, where the system exchanges both energy and particles with a reservoir at temperature T and chemical potential \mu.
The payoff is spectacular: once N is free to fluctuate, the single-particle levels become independent. The grand partition function factorizes into one factor per level.
The grand partition function factorizes over single-particle levels i. Each factor is a sum over the allowed occupation numbers n_i of that one level. This one step is the whole engine of quantum statistics.
Summing the states, level by level
Now the two tribes part ways in the range of the sum. For fermions the Pauli principle allows only n_i = 0 or $1$, so the sum has just two terms. For bosons any n_i = 0, 1, 2, \dots is allowed, and the sum is a geometric series.
Fermi-Dirac: two terms (empty or singly filled). Bose-Einstein: a geometric series, which converges only if μ lies below every level's energy.
The mean occupation of level i follows by differentiating: \bar n_i = -\frac{1}{\beta}\frac{\partial \ln \mathcal{Z}_i}{\partial \varepsilon_i}. Carrying out the derivative for both cases gives the two famous distributions.
The master formula
The single equation that runs the rest of the track. The only difference between the two great quantum gases — the Fermi-Dirac and Bose-Einstein distributions — is the sign in the denominator: +1 for fermions, −1 for bosons.
Read the two limits. For fermions the $+1$ caps occupancy at one: at T=0, \bar n is exactly $1$ below \mu and $0$ above it — the sharp Fermi step. For bosons the $-1$ makes \bar n blow up as \varepsilon \to \mu, which is why \mu must stay below the ground-state energy and why bosons pile up there.
Chemical potential, fugacity, and the classical limit
The chemical potential \mu is fixed, implicitly, by demanding that the occupations add up to the actual particle number, N = \sum_i \bar n_i. It is the energy cost of adding one more particle at fixed entropy and volume. The combination z \equiv e^{\beta\mu}, the fugacity, is often more convenient.
Worked example — recovering the classical gas. When the gas is dilute and hot, states are almost never occupied, so \bar n \ll 1. This requires e^{\beta(\varepsilon - \mu)} \gg 1, so the \pm 1 in the denominator becomes negligible.
Both quantum distributions collapse to the same exponential Maxwell-Boltzmann form. The sign of the particle (boson or fermion) no longer matters — the tell-tale of the classical regime.