Consider a collection of N molecules of a large number of energy states, E1, E2, E3 etc such that there are N1 molecules in state E1, N2 in E2 and so on. The nature of energy is immaterial. The number of ways in which N molecules can be accommodated in various states is given by

The underlying idea is that the state of the system would be state if W is a maximum.
Taking logs on both sides and applying Stirling’s approximation ln W =

If the system is in a state of maximum thermodynamic probability, the variation of W with respect to change in Ni is zero, that is

We now use the Lagrange method of undetermined multipliers. Multiplying (5) by α and (6) by β and adding to (7), we get

