At thermodynamic equilibrium, the likelihood of a state of energy  being filled with an electron is given by the Fermi–Dirac distribution, a thermodynamic distribution that takes into account the Pauli exclusion principle:
where:
* is the product of Boltzmann's constant and temperature, and
* is the total chemical potential of electrons, or Fermi level (in semiconductor physics, this quantity is more often denoted ). The Fermi level of a solid is directly related to the voltage on that solid, as measured with a voltmeter. Conventionally, in band structure plots the Fermi level is taken to be the zero of energy (an arbitrary choice).
The density of electrons in the material is simply the integral of the Fermi–Dirac distribution times the density of states:
Although there are an infinite number of bands and thus an infinite number of states, there are only a finite number of electrons to place in these bands.
The preferred value for the number of electrons is a consequence of electrostatics: even though the surface of a material can be charged, the internal bulk of a material prefers to be charge neutral.
The condition of charge neutrality means that  must match the density of protons in the material. For this to occur, the material electrostatically adjusts itself, shifting its band structure up or down in energy (thereby shifting ), until it is at the correct equilibrium with respect to the Fermi level.