Boltzmann distribution and state degeneracy (source code)

= Boltzmann distribution and state degeneracy
{c}
{title2=$P(E)=g(E)e^{-\beta E}/Z$}

Group <microstates> by their <energy> $E$. The <state degeneracy> $g(E)$ counts how many <microstates> have that <energy>; their aggregate <probability> is
$$
P(E)=\sum_{i:E_i=E}p_i=\frac{g(E)e^{-\beta E}}{Z},\qquad
Z=\sum_{\text{distinct }E}g(E)e^{-\beta E}.
$$
Here $P(E)$ is the <probability> of the <macrostate> retaining only <energy>, while $p_i$ is the <probability> of one individual <microstate>. For two such <macrostates>,
$$
\frac{P(E_a)}{P(E_b)}=\frac{g(E_a)}{g(E_b)}e^{-\beta(E_a-E_b)}.
$$
Counting more <microstates> can compensate for a smaller <Boltzmann factor>. Omitting the <state degeneracy> confuses a sum over <microstates> with a sum over distinct <energies>. https://ocw.mit.edu/courses/5-62-physical-chemistry-ii-spring-2008/bda82786b6014d3f468798339f658629_03_562ln08.pdf[MIT 5.62, spring 2008, lecture 3, page 4: degeneracy and the aggregate energy probability]{ref}