In order to calculate expectation values such as the mean energy ⟨E⟩ or magnetization ⟨M⟩ in statistical physics at a given temperature, we need a probability distribution Pi(β)=e−βEiZ with β=1/kT being the inverse temperature, k the Boltzmann constant, Ei is the energy of a state i while Z is the partition function for the canonical ensemble defined as Z=M∑i=1e−βEi, where the sum extends over all microstates M. Pi expresses the probability of finding the system in a given configuration i.