  In these notes, we study a class of grand-canonical partition functions with
a kernel depending on a small parameter $\epsilon$. This class is directly
relevant to Nekrasov partition functions of $\mathcal{N}=2$ SUSY gauge theories
on the 4d $\Omega$-background, for which $\epsilon$ is identified with one of
the equivariant deformation parameter. In the Nekrasov-Shatashvili limit
$\epsilon\to0$, we show that the free energy is given by an on-shell effective
action. The equations of motion take the form of a TBA equation. The free
energy is identified with the Yang-Yang functional of the corresponding system
of Bethe roots. We further study the associated canonical model that takes the
form of a generalized matrix model. Confinement of the eigenvalues by the
short-range potential is observed. In the limit where this confining potential
becomes weak, the collective field theory formulation is recovered. Finally, we
discuss the connection with the alternative expression of instanton partition
functions as sums over Young tableaux.
