There are many ways to arrive at the Gibbs entropy formula
which is actually identical, except for units, to the Shannon entropy formula. Here I document a relatively straightforward derivation of the formula which might be the easiest route to develop intuition for undergraduate students who already know the formula for the Boltzmann entropy,
where is the effective number of configurations of an isolated system with total energy . This derivation is not new of course, but I decided to write it up anyway because it is a particularly elegant argument and is not always given emphasis in the usual textbooks.
Let us start by considering some general statistical ensemble such that a state has energy and probability which is the same for all states with the same energy . For fixed energy we can assume, from the principle of equal a priori probabilities, which is valid in the microcanonical ensemble, that
Hence we obtain for the Boltzmann entropy
For our general ensemble, the mean entropy is given by the weighted average, over all possible states, of the Boltzmann entropy, according to
from which we obtain the famous Gibbs formula for the Boltzmann-Gibbs entropy: