A partition function is a sum or integral of statistical weights over the possible states of a system. In statistical mechanics, it normalizes the probabilities of microscopic states and provides a route from their energies to macroscopic properties in thermodynamic equilibrium. Related functions appear in probabilistic modeling, where they convert unnormalized weights into a probability distribution. Its usual symbol is , although notation depends on the ensemble and application. (damtp.cam.ac.uk)
Canonical definition
The canonical ensemble describes a system that exchanges energy with a thermal reservoir while its volume and particle number remain fixed. At absolute temperature , its partition function is
where is the energy of microscopic state , and is the Boltzmann constant. The resulting Boltzmann distribution assigns probability
Thus ensures that ; it is not itself a probability. States with higher energies receive smaller individual weights at positive temperature. (damtp.cam.ac.uk)
The sum counts states rather than merely distinct energy values. If an energy level contains states, its contribution is . Consequently, numerous higher-energy states can collectively outweigh a small number of lower-energy states. For infinite state spaces, the sum must converge for the normalized distribution to exist. (damtp.cam.ac.uk)
Thermodynamic information
The canonical partition function determines the Helmholtz free energy:
Other quantities follow from derivatives. For a Hamiltonian without explicit temperature dependence, the internal energy is
The held-fixed variables matter: different constraints lead to different thermodynamic derivatives. These relations make the partition function more than a normalization device—it encodes the equilibrium equation of state and thermodynamic response. (damtp.cam.ac.uk)
Its second derivative measures energy fluctuations:
This variance is related to the constant-volume heat capacity by
Macroscopic thermal response is therefore directly connected to microscopic fluctuations. (damtp.cam.ac.uk)
Quantum and classical forms
In quantum mechanics, the canonical definition can be written independently of a chosen basis:
where is the Hamiltonian operator and is the trace. Evaluating the trace in an energy eigenbasis recovers the sum over states. The equilibrium density matrix is correspondingly . (damtp.cam.ac.uk)
For identical, structureless particles in three dimensions, the classical Maxwell–Boltzmann expression is an integral over phase space:
Here is the Planck constant. The phase-space measure divided by makes the statistical count dimensionless, while corrects the overcounting caused by permuting identical particles. This classical expression does not replace the appropriate quantum treatment when quantum statistical effects are important. (damtp.cam.ac.uk)
Factorization and a two-state example
When distinguishable subsystems are independent and their energies add, their partition functions multiply:
This simplifies calculations because becomes a sum, and the corresponding free energies are additive. Interactions generally prevent this simple factorization. (damtp.cam.ac.uk)
For a single system with two nondegenerate levels, and ,
At low positive temperature, the lower state dominates; at temperatures large compared with , the two probabilities approach equality. For independent distinguishable copies, . This example illustrates how state counting and thermal weighting are combined in one expression. (damtp.cam.ac.uk)
Other ensembles
The grand canonical ensemble allows exchange of particles as well as energy with a reservoir. Its grand partition function is
where is the chemical potential. The factor is called fugacity. The associated grand potential is
and the mean particle number follows from . Choosing an ensemble determines which states are included and how they are weighted. (damtp.cam.ac.uk)
Probability models and computation
In machine learning, an energy-based model often takes the form
with a sum replacing the integral for discrete states. Here “energy” can be a learned score rather than physical energy, and any inverse-temperature factor may be absorbed into its definition. A finite, positive is required for normalization. (deeplearningbook.org)
Computing this function can be difficult because it aggregates weights across a high-dimensional state space. In maximum likelihood estimation, derivatives of introduce model expectations. Markov chain Monte Carlo can approximate those expectations without directly evaluating the normalization constant. Estimating itself is a separate task; annealed importance sampling addresses it by connecting a tractable reference distribution to the target through intermediate distributions. (deeplearningbook.org)