Suppose we have a canonical ensemble, where $N$ particles have been divided among $\epsilon_i$ energy levels, each with degeneracy $g_i$. The partition function for a single particle is given by : $$Z_{sp}=\sum_{i}^{r} g_i e^{-\beta\epsilon_i}$$
There are $r$ total energy levels here.
Anyway, the partition function for all the $N$ particles can be found using the same formula, by checking all the possible combinations and values of total energy due to each of these particles, which would be a long and tedious process. However, we can write the $N$ particle partition function as follows :
$$Z_{N}=\prod_{i}^{N}(Z_{sp})_i$$
Now we know that the probability of the system being in a particular 'energy level' is :
$$P(\epsilon_i)=\frac{g_i e^{-\beta \epsilon_i}}{Z}$$
If we cared about a particular state, and not the energy level, then we would just drop the $g_i$ term in the numerator I suppose. My question is, what exactly is $Z$ in this example? Is it $Z_{sp}$ or $Z_N$ ? According to an example in my book, it should be the single-particle partition function. However my system consists of $N$ particles, so shouldn't we consider the $N$ particle partition function instead ?
Suppose my particles are bosons or classical particles, in the sense that there is no limitation on the number of particles in a state, we can say the following :
$$P(\epsilon_i)= \frac{n_i}{N}$$
Hence, we are finding the number of particles with energy $\epsilon_i$ divided by the total number of particles. Hence we can write :
$$n_i=N\frac{g_i e^{-\beta \epsilon_i}}{Z}$$
But now, shouldn't we consider the partition function of all these $N$ particles?
According to my book, the number of particles in a particular energy level is the product of the total number of particles and the probability of a single particle in that level. Because of this, they use the single-particle partition function. This seems a little wrong to me. Since we are talking about $N$ particles, shouldn't we just use the $N$ particle partition function instead ? The probability of the system in a particular energy level is given using the $N$ particle partition function, since there are $N$ particles in the system. So, by that argument, shouldn't number of particles in a particular energy levels also be given using the $N$ particle.
So, if I want to find the number of particles in a particular energy level, in a system of $N$ particles, what should I use :
$$n_i=N\frac{g_i e^{-\beta \epsilon_i}}{Z_{sp}} \space \space or\space\space \frac{g_i e^{-\beta \epsilon_i}}{Z_{N}}$$
Any help on understanding this concept would be highly appreciated. Thanks !