{
  "id": "partition-function",
  "title": "Partition Function",
  "lang": "en",
  "source_lang": "en",
  "summary": "A partition function normalizes statistical weights and connects microscopic states to thermodynamic properties and probabilistic models.",
  "category": "science",
  "subcategory": "physics",
  "type": "concept",
  "aliases": [
    "Statistical sum",
    "Sum over states"
  ],
  "generated_at": "2026-10-04",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/partition-function/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/partition-function/",
      "json": "https://aiwiki.page/zh/partition-function.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "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 \\(Z\\), although notation depends on the ensemble and application. (damtp.cam.ac.uk)"
    },
    {
      "heading": "Canonical definition",
      "text": "The canonical ensemble describes a system that exchanges energy with a thermal reservoir while its volume \\(V\\) and particle number \\(N\\) remain fixed. At absolute temperature \\(T\\), its partition function is\n\n\\[Z(T,V,N)=\\sum_i e^{-\\beta E_i}, \\qquad \\beta=\\frac{1}{k_{\\mathrm B}T},\\]\n\nwhere \\(E_i\\) is the energy of microscopic state \\(i\\), and \\(k_{\\mathrm B}\\) is the Boltzmann constant. The resulting Boltzmann distribution assigns probability\n\n\\[p_i=\\frac{e^{-\\beta E_i}}{Z}.\\]\n\nThus \\(Z\\) ensures that \\(\\sum_i p_i=1\\); it is not itself a probability. States with higher energies receive smaller individual weights at positive temperature. (damtp.cam.ac.uk)\n\nThe sum counts states rather than merely distinct energy values. If an energy level \\(E_a\\) contains \\(g_a\\) states, its contribution is \\(g_a e^{-\\beta E_a}\\). 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)"
    },
    {
      "heading": "Thermodynamic information",
      "text": "The canonical partition function determines the Helmholtz free energy:\n\n\\[F=-k_{\\mathrm B}T\\ln Z.\\]\n\nOther quantities follow from derivatives. For a Hamiltonian without explicit temperature dependence, the internal energy is\n\n\\[U=\\langle E\\rangle =-\\left(\\frac{\\partial\\ln Z}{\\partial\\beta}\\right)_{V,N}.\\]\n\nThe entropy and pressure are\n\n\\[S=k_{\\mathrm B}(\\ln Z+\\beta U), \\qquad P=k_{\\mathrm B}T \\left(\\frac{\\partial\\ln Z}{\\partial V}\\right)_{T,N}.\\]\n\nThe 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)\n\nIts second derivative measures energy fluctuations:\n\n\\[\\frac{\\partial^2\\ln Z}{\\partial\\beta^2} =\\langle E^2\\rangle-\\langle E\\rangle^2.\\]\n\nThis variance is related to the constant-volume heat capacity by\n\n\\[C_V=\\frac{\\langle E^2\\rangle-\\langle E\\rangle^2} {k_{\\mathrm B}T^2}.\\]\n\nMacroscopic thermal response is therefore directly connected to microscopic fluctuations. (damtp.cam.ac.uk)"
    },
    {
      "heading": "Quantum and classical forms",
      "text": "In quantum mechanics, the canonical definition can be written independently of a chosen basis:\n\n\\[Z=\\operatorname{Tr}(e^{-\\beta\\hat H}),\\]\n\nwhere \\(\\hat H\\) is the Hamiltonian operator and \\(\\operatorname{Tr}\\) is the trace. Evaluating the trace in an energy eigenbasis recovers the sum over states. The equilibrium density matrix is correspondingly \\(\\rho=e^{-\\beta\\hat H}/Z\\). (damtp.cam.ac.uk)\n\nFor \\(N\\) identical, structureless particles in three dimensions, the classical Maxwell–Boltzmann expression is an integral over phase space:\n\n\\[Z_N=\\frac{1}{N!h^{3N}} \\int e^{-\\beta H(\\mathbf q,\\mathbf p)} \\,d^{3N}q\\,d^{3N}p.\\]\n\nHere \\(h\\) is the Planck constant. The phase-space measure divided by \\(h^{3N}\\) makes the statistical count dimensionless, while \\(N!\\) 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)"
    },
    {
      "heading": "Factorization and a two-state example",
      "text": "When distinguishable subsystems are independent and their energies add, their partition functions multiply:\n\n\\[Z_{\\mathrm{total}}=\\prod_a Z_a.\\]\n\nThis simplifies calculations because \\(\\ln Z_{\\mathrm{total}}\\) becomes a sum, and the corresponding free energies are additive. Interactions generally prevent this simple factorization. (damtp.cam.ac.uk)\n\nFor a single system with two nondegenerate levels, \\(0\\) and \\(\\epsilon>0\\),\n\n\\[Z_1=1+e^{-\\beta\\epsilon}, \\qquad U_1=\\frac{\\epsilon}{1+e^{\\beta\\epsilon}}.\\]\n\nAt low positive temperature, the lower state dominates; at temperatures large compared with \\(\\epsilon/k_{\\mathrm B}\\), the two probabilities approach equality. For \\(N\\) independent distinguishable copies, \\(Z_N=(Z_1)^N\\). This example illustrates how state counting and thermal weighting are combined in one expression. (damtp.cam.ac.uk)"
    },
    {
      "heading": "Other ensembles",
      "text": "The grand canonical ensemble allows exchange of particles as well as energy with a reservoir. Its grand partition function is\n\n\\[\\Xi(T,V,\\mu)= \\sum_{N=0}^{\\infty}e^{\\beta\\mu N}Z_N(T,V),\\]\n\nwhere \\(\\mu\\) is the chemical potential. The factor \\(e^{\\beta\\mu}\\) is called fugacity. The associated grand potential is\n\n\\[\\Omega=-k_{\\mathrm B}T\\ln\\Xi,\\]\n\nand the mean particle number follows from\n\\(\\langle N\\rangle=\\beta^{-1}(\\partial\\ln\\Xi/\\partial\\mu)_{T,V}\\).\nChoosing an ensemble determines which states are included and how they are weighted. (damtp.cam.ac.uk)"
    },
    {
      "heading": "Probability models and computation",
      "text": "In machine learning, an energy-based model often takes the form\n\n\\[p_\\theta(x)=\\frac{e^{-E_\\theta(x)}}{Z(\\theta)}, \\qquad Z(\\theta)=\\int e^{-E_\\theta(x)}\\,dx,\\]\n\nwith 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 \\(Z(\\theta)\\) is required for normalization. (deeplearningbook.org)\n\nComputing this function can be difficult because it aggregates weights across a high-dimensional state space. In maximum likelihood estimation, derivatives of \\(\\ln Z(\\theta)\\) introduce model expectations. Markov chain Monte Carlo can approximate those expectations without directly evaluating the normalization constant. Estimating \\(Z\\) itself is a separate task; annealed importance sampling addresses it by connecting a tractable reference distribution to the target through intermediate distributions. (deeplearningbook.org)"
    }
  ],
  "links": [
    "statistical-mechanics",
    "thermodynamic-equilibrium",
    "probability-distribution",
    "canonical-ensemble",
    "temperature",
    "energy",
    "boltzmann-constant",
    "boltzmann-distribution",
    "helmholtz-free-energy",
    "internal-energy",
    "entropy",
    "pressure",
    "variance",
    "heat-capacity",
    "quantum-mechanics",
    "hamiltonian-operator",
    "matrix-trace",
    "density-matrix",
    "phase-space",
    "planck-constant",
    "grand-canonical-ensemble",
    "chemical-potential",
    "machine-learning",
    "energy-based-model",
    "maximum-likelihood-estimation",
    "markov-chain-monte-carlo"
  ],
  "sources": [
    {
      "title": "damtp.cam.ac.uk/user/tong/statphys/one.pdf",
      "url": "https://www.damtp.cam.ac.uk/user/tong/statphys/one.pdf"
    },
    {
      "title": "damtp.cam.ac.uk/user/tong/statphys/statmechhtml/S1.html",
      "url": "https://www.damtp.cam.ac.uk/user/tong/statphys/statmechhtml/S1.html"
    },
    {
      "title": "damtp.cam.ac.uk/user/dt281/statphys/one.pdf",
      "url": "https://www.damtp.cam.ac.uk/user/dt281/statphys/one.pdf"
    },
    {
      "title": "damtp.cam.ac.uk/user/us248/Lectures/Notes/statphys.pdf",
      "url": "https://www.damtp.cam.ac.uk/user/us248/Lectures/Notes/statphys.pdf"
    },
    {
      "title": "damtp.cam.ac.uk/user/examples/D20a.pdf",
      "url": "https://www.damtp.cam.ac.uk/user/examples/D20a.pdf"
    },
    {
      "title": "deeplearningbook.org/contents/graphical_models.html",
      "url": "https://www.deeplearningbook.org/contents/graphical_models.html"
    },
    {
      "title": "deeplearningbook.org/contents/partition.html",
      "url": "https://www.deeplearningbook.org/contents/partition.html"
    }
  ],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}