In order to calculate expectation values such as the mean energy \( \langle E \rangle \) or magnetization \( \langle {\cal M} \rangle \) in statistical physics at a given temperature, we need a probability distribution $$ \begin{equation*} P_i(\beta) = \frac{e^{-\beta E_i}}{Z} \end{equation*} $$ with \( \beta=1/kT \) being the inverse temperature, \( k \) the Boltzmann constant, \( E_i \) is the energy of a state \( i \) while \( Z \) is the partition function for the canonical ensemble defined as $$ \begin{equation*} Z=\sum_{i=1}^{M}e^{-\beta E_i}, \end{equation*} $$ where the sum extends over all microstates \( M \). \( P_i \) expresses the probability of finding the system in a given configuration \( i \).