I heard all the theories about temperature PH etc...
It's based on demographics, the species will always magically create more of what it statically needs.
I can see it on my shrimp tank that I started. At some point in the beginning all the males died. for a X reason... I was left with 7 females and one of them was berried. nearly all the babies she had are looking like males for the moment. It's absolutely impossible that they have been conceived in this tank, but "it" knew what the community needs.
In a free for all slightly overfed Guppy tank. Males and Females will come in waves. But there will always be enough boys for all the ladies to crush on.