If a system has finitely many states \(i=1, \ldots, n\) with energies \(E_{i}\), we say it's in thermal equilibrium if it maximizes entropy subject to a constraint on its expected energy:

\[

\sum_{i=1}^{n} E_{i} p_{i}=E

\]

where \(p_{i}\) is the probability it's in the \(i\) th state. We then have

\[

p_{i} \propto \exp \left(-\beta E_{i}\right)

\]

where \(\beta=1 / k T\) is the coolness, \(k\) is Boltzmann's constant, and the temperature \(T\) can be positive, negative, or even infinite: