I was going through my lecture notes and I found something I could not quite understand. First, it starts by deriving an expression for the information entropy (as used in physics?):
Let $p_i$ be the probability of finding the system in microstate $i$. With the total number of accessible Microstates $N(A)$, this can be written $p_i = \frac{1}{N}$ for all microstates compatible with the macrostate $A$. We can write $\ln N(A) = -1\cdot\ln p_i = -\left(\sum_{i = 1}^{N(A)}p_i\right)\ln p_i$ due to the normalization of the $p_i$. [...]
Therefore, we can write for the information entropy of a macrostate $A$: $$S(A) = -k_\mathrm{B} \sum_{i = 1}^{N(A)}p_i\ln p_i$$
Later, it tries to derive the Boltzmann distribution for the ideal gas:
We will do so by finding the extremum of $$\phi = S(A) - \lambda_1\left(\sum_i p_i - 1\right) - \lambda_2 \left(\sum_i p_i E_i - E_\mathrm{avg}\right) $$ using the method of Lagrange multipliers. With $S(A) = -k_\mathrm{B} \sum_{i = 1}^{N(A)}p_i\ln p_i$.
It goes on to find the correct formula.
My question is, why this expression for the entropy $S(A)$ can be used, even though for the second example the $p_i$ are obviously not constant and equal to $\frac{1}{N}$?