The Boltzmann distribution gives the population of the states at one energy relative to the population of states in the ground state:(1). This expression can be used when we are interested in the population of high energy excited states, but more often we are interested in entire systems of particles.

To deal with the macroscopic behaviour of systems of particles, we must use the Boltzmann distribution expression to find how many of the particles occupy each energy state. The Boltzmann distribution must be applied to each of the very many states available to the particles. This can be done by summing over all the available states, resulting in a function called the partition function., defined as

The value of q can be calculated for any particular type of atom or molecular motion if the energies of the allowed states are known.

We can write (1) in a more convenient form. The number of particles is given by

Henceso we can write (1) as

The thermal energy of a system of particles can be expressed in terms of the partition function.

Hence