*"In a country where couples stop having children once they've given birth to a boy,
what is the ratio of males to females in the country?"*

My first intuition was that there would be more boys than girls, but by how much I was unsure. Well the number of boys in each family will be 1, so how many girls will there be? Well chances are, ½ of the families will have a girl first, and of those there is ½ the chance again that they will have another girl, which means the total number of girls will be ½+¼+⅛+… or representing the sum of this geometric series (or a visual proof) in standard mathematical notation:

So the ratio will be 1:1, which surprised me at least. For those wanting to analyse male/female probabilities in more depth, this is an example of a Bernoulli process. The above series converges very quickly and so applies to standard sized families as verified by the following unix command.

$ echo "print sum(1.0/(2<<n) for n in range(10))" | python 0.9990234375

With this info and thinking about it intuitively again, couples only decide not to have another child. In the pool of children already born, the ratio of male to female will be equal. I.E. even though the male:female ratio within any family is only sometimes 1:1, across the whole population the ratio will be 1:1. Now male:female ratios are generally not exactly 1:1 due to various factors mentioned below, but the principle still applies. I.E. one can't change the ratio using passive selection, as verified by the more general command below:

$ m2f=1.09 $ echo "print '%.2f:1' % (1/sum((1/(1+$m2f))**n for n in range(1,10)))" | python 1.09:1

But that got me thinking about the current male:female ratio statistics in China and more recently India. The current preponderance of males can't be from choices about whether to have more children or not, and must be from sex-selective abortion resulting from China's "one-child" policy. There is the factor of Hepatitis B infection which by poorly understood processes skews the male:female ratio to 1.75:1 for infected couples, but that is not the main factor in China. Chinese statistics report that the male:female ratio imbalance rose from 1.09:1 in 1982 to 1.13:1 in 1989 and 1.18:1 in 2000. The 1982 ratio likely reflected Hepatitis B prevalence but the subsequent increases probably reflect sex-selection. It gets even worse in the southern Hainan province for example where the ratio is around 1.35:1

Another factor to consider is hormone mimicking pollutants which across the northern hemisphere are causing more girls to be born, and is the suspected cause of more girls than boys being born in the US and Japan currently. In Greenland and northern Russia these pollutants have tipped the male:female gender ratio alarmingly to 0.5:1. If one factors this into the Chinese equation, it points to an even greater sex-selective abortion problem, especially considering China's environmental record.

It will be interesting if not worrying to see the long term social impact of this disparity.

[**Update:** May 2017. It seems the main gender ratio imbalance is due to failure
to register females, and this has diminished over time as those kids are registered
for school or to allow marriage. This is depicted for both India and China
in Max Galka's tweet.]