One of the most used ensembles is the canonical one, which is related to the microcanonical ensemble via a Legendre transformation. The temperature is an intensive variable in this ensemble whereas the energy follows as an expectation value. In order to calculate expectation values such as the mean energy \( \langle E \rangle \) at a given temperature, we need a probability distribution. It is given by the Boltzmann distribution $$ \begin{equation*} P_i(\beta) = \frac{e^{-\beta E_i}}{Z} \end{equation*} $$ with \( \beta=1/k_BT \) being the inverse temperature, \( k_B \) is the Boltzmann constant, \( E_i \) is the energy of a microstate \( i \) while \( Z \) is the partition function for the canonical ensemble defined as