We are going to calculate from among all the possible macrostates of the system the one that has the largest number of microstates. Thus, the calculation of any thermodynamic quantity is carried out neglecting all the macrostates except the most probable. Mathematically we must calculate $N_{1},N_{2},.....,N_{r}$ so that W takes the maximum value. Where W is given by:

\begin{equation} W=N!\prod_{k}\frac{g_{k}^{N_{k}}}{N_{k}!} \label{ec3} \end{equation}

Taking neperians at (\ref{ec3})

\begin{equation} lnW=lnN!+\sum\left(N_{k}lng_{k}-lnN_{k}!\right) \label{ec4} \end{equation}

Applying in (~\ref{ec4}) the Stirling approximation $lnN!=NlnN-N$:

\begin{equation} lnW=NlnN-N+\sum_{k}N_{k}lng_{k} -\sum_{k}\left(N_{k}lnN_{k}-N_{k}\right) \label{ec5} \end{equation}

Since $\sum_{k}N_{k}=N$ , the equation (\ref{ec5}) can be simplified to

\begin{equation} lnW=NlnN+\sum_{k}N_{k}lng_{k}-\sum_{k}N_{k}lnN_{k} \label{ ec6} \end{equation}

To maximize $lnW$ we apply the Lagrange indeterminate multipliers technique, imposing the conditions: $\sum_{k}N_{k}=N$ and $\sum_{k}N_{k} \epsilon_{k}=E$ We build the Lagrangian from the function to be maximized ($lnW$), and from the conditions that must be fulfilled multiplied by the coefficients $\alpha$ and $\beta$.

\begin{equation} L=lnW-\alpha\sum_{k}N_{k}-\beta\sum_{k}N_{k}\epsilon_{k} \label{ec7} \end{equation}

Differentiating the Lagrangian with respect to $N_{i}$ (number of particles in state $i$ for the most probable macrostate) and equating to zero, we obtain:

\begin{equation} \frac{\partial{L}}{\partial{ N_{i}}}=\frac{\partial{lnW}}{\partial{N_{i}}}-\alpha-\beta{\epsilon}_{i}=0 \label{ec8} \end{equation}

$\frac{\partial{lnW}}{\partial{N_{i}}}$ is obtained by deriving from equation (\ref{ec6})

\begin{equation} \frac{\partial{lnW}} {\partial{N_{i}}}=lng_{i}-lnN_{i}-1 \label{ec9} \end{equation}

Substituting (~\ref{ec9}) into (~\ref{ec8}) it is obtained:

\begin{equation} lng_{i}-lnN_{i}-1-\alpha-\beta{\epsilon_{i}}=0 \label{ec10} \end{equation}

Applying natural properties and grouping terms:

\begin{equation} ln\frac{N_{i}}{g_{i}}=-(1+\alpha)-\beta{\epsilon_{i}} \label{ec11} \end{equation}

Solving for $\frac{N_{i}}{g_{i}}$


Taking summations in (~\ref{ec12}):

\begin{equation} \sum_{i}{N_{i}}=e^{-\left(\alpha+1\right)}\sum_{i}g_{i}e^{-\beta{\epsilon_{i}}} \label{ec13} \end{equation}

As $\sum_{i}{N_{i}}= N$.

\begin{equation} N=e^{-\left(\alpha+1\right)}\sum_{i}g_{i}e^{-\beta{\epsilon_{i}}} \label{ec14} \end{equation}

Where $q=\sum_{i}g_{i}e^{-\beta{\epsilon_{i}}}$, is the {\bf partition function of the system}. Therefore:

\begin{equation} e^{-(\alpha{+1})}=\frac{N}{q} \label{ec15} \end{equation}

Substituting the equation (~\ref{ec15} ) in (\ref{ec12}) and solving for $N_{i}$ gives us:

\begin{equation} N_{i}=N\frac{g_{i}e^{-\beta{\epsilon_{i }}}}{q} \label{ec16} \end{equation}

The values of $N_{i}$ given by the equation (\ref{ec16}) are those that maximize $W$. That is, the calculated distribution is the one with the largest number of microstates.