In this type of ensemble the system can also exchange particles with the reservoir. The equilibrium within respect particles exchange is described by an intensive property of the system, called chemical potential
. Condition of equilibrium:
. More precisely:

The probability that the system has a given energy
and number of particles
is given by:

Where
is the gran-canonical partition function:

In such an ensemble we also have:

We can evaluate the mean value of energy and number of particles:
Since
we can derive an expression for
:

When we have to evaluate the partition function, we have to distinguish two cases: bosons and fermions.
From where we can derive the mean number of particles per energy level in the two cases. More precisely what we do derive are two distributions: the Fermi-Dirac and the Bose-Einstein distributions.