Hi Sabrina
I cannot give you the actual formulas in PDFgui, but I can describe roughly what is going on.
When you have a sample with two or more phases we refine a scale factor for each phase. A scale factor represent the number of photons/neutrons that the corresponding phase sends to the detector. This depends on several factors, for example the scattering strength of the atoms in the phase and the number of X-rays/neutrons hitting the phase. Basically all these factors are the same for all the phases, the only difference between the phases are the atomic composition which determines the scattering strength of the two phases.
So the scale factor for each phase needs to be normalised with the scattering strength of the atoms in the phase.
For example consider a 1:1 atomic mixture of pure Li and pure C (and lets assume the unit cell have the same size for both phases. A unrealistic assumption, but just to make it simple) where we measure a X-ray PDF. C contains twice as many electrons as Li and therefore scatters 4 times as many electrons, since the scattering strength is roughly equal to Z^2. This means that the scale factor of the C phase will be 4 times that of the Li phase as the probability for C to scatter a X-ray is 4 times as large. So to get the atomic percentage we need to divide the scale factor of carbon with 4 and then take the ration between the two scale factors. When we know the atomic percentage the rest is straight forward. Since C is roughly twice as heavy as Li the weight ratio will be roughly 2/3 C and 1 Li. In this case we said the unit cell was the same size so here the ratio of the unit cells would be 1:1.
The amount of units cells is not as simple to calculate because it depends on the volume of the unit cell and the number of atoms in the unit cell. You could have a phase with a very large unit cell with very few extremely heavy atoms, mixed with a phase with a small unit cell with lighter atoms. Then the large unit cell phase would only make out few of the total number of atoms (the atomic percentage would favour the small unit cell phase) and most of the unit cells would come from the small unit cell phase, but the the weight percent would be dominated by the large unit cell phase.
In summary, all PDFgui does is to take the scale factor for each phase and normalise it with the number of atoms in the unit cell, the unit cells volume and the scattering length of all the atoms.
Hope that answers your question.
Mikkel