Statistical entropy is a concept in thermodynamics that quantifies the number of different ways a system can be arranged while still maintaining its macroscopic properties.

The total energy of a system, \(E\), is given by eq2. Its total differential is:
$$dE=\sum_i\varepsilon_idn_i+\sum_in_id\varepsilon_i$$
Consider the transfer of heat to a closed system of particles. If the volume of the system is constant, then no work is done on the system and the energy level of each state is unchanged \(d\varepsilon_i=0\). However, the population of particles in each state \(dn_i\) varies according to temperature. Hence,
$$dE=\sum_i\varepsilon_idn_i\;\;\;\;\;\;\;\;26$$
If we interpret \(E\) as the internal energy of the system, \(U\), then according to the first law of thermodynamics of a constant volume system,
$$dE=dU=dq\;\;\;\;\;\;\;\;27$$
For a reversible transfer of heat, the second law of thermodynamics states that \(\small{dS=\frac{dq}{T}}\). Combining \(dS\), eq24a, eq26 and eq27,
$$dS=k\beta\sum_i\varepsilon_idn_i\;\;\;\;\;\;\;\;28$$
Substituting eq16 in eq28,
$$dS=k\sum_i\biggr(\frac{\partial lnW}{\partial n_i}\biggr)dn_i+k\alpha\sum_idn_i$$
Since the total number of particles for a closed system is constant, \(\small{\sum_idn_i=0}\) and
$$dS=k\sum_i\biggr(\frac{\partial lnW}{\partial n_i}\biggr)dn_i\;\;\;\;\;\;\;\;29$$
Substituting eq4 in eq29, we have \(dS=kdlnW\) or the integrated form:
$$S=klnW\;\;\;\;\;\;\;\;30$$
where \(S\) is the statistical entropy.