Solution (source code)

= Solution

The expression is the <canonical partition function> for a system in <thermal equilibrium> with a large <heat bath> at fixed <temperature> $T$. The system exchanges <energy> with the bath, while its particle number and external mechanical parameters, such as <volume>, are fixed. The bath is large enough that its <temperature> is not appreciably changed by this exchange.

The system has allowed <energy levels> $\epsilon_j$. The index $j$ labels distinct <energy> values, and the integer <degeneracy factor> $g_j$ counts distinct <quantum states> with that same <energy>. $k_B$ is the <Boltzmann constant>, and $\exp[-\epsilon_j/(k_BT)]$ is a state's <Boltzmann factor>. The dimensionless sum $Z$ normalizes the probabilities:
$$
\boxed{P(\text{one state at }\epsilon_j)=\frac{e^{-\epsilon_j/(k_BT)}}Z,\qquad
P(\text{level }j)=\frac{g_je^{-\epsilon_j/(k_BT)}}Z.}
$$
Thus the degeneracy multiplies the probability of occupying the level, not the probability assigned to each individual state within it.

The canonical model is not restricted to a classical <ideal gas>. It applies to a quantum rotor, for example, provided the sum counts all of that system's allowed states with their proper degeneracies. For a many-particle system, $\epsilon_j$ would be the <energy> of a many-particle state, with any quantum-statistical restrictions already built into the state count.