Let's assume you wish to have children—moreover, you want just as many girls as boys. In fact, you are so very much determined that you set out to not stop getting kids until the number of girls matches precisely the number of boys. How big a family will that make you, on average?

For simplification, we will assume that the chances for getting boys and girls are equal and independent for each kid, and that your babies come in packets of one.

So, for instance, there is a 50% chance that your first two babies are a girl and a boy—you thus happily stopping with two kids. On the other hand, there's a 12.5% chance that your first three kids are girls in which case your family is probably going to be pretty big. Take a moment to make a guess what the expected number of kids will be.

*Personal remark:* I guessed it would be about 6 which I thought an unbiased guess based on the one sample my parents provided. Well, actually I missed the fact that me and my siblings arrived as `M,M,F,F,M,F`

. Thus my parents really provided two samples: one leading to four children and a second leading to two children. Thus my unbiased guess should have been 3 (but I would have reckoned that as too low).

The above problem was told to me my James Wan and below are our thoughts on it.

## A mathematical model

Let's do some mathematical modeling and introduce a random variable \(X_k\) which is \(1\) if the \(k\)th kid is a girl and \(0\) otherwise. Thus \(S_n = \sum_{k=1}^n X_k\) is the number of girls among the first \(n\) kids, and we know that \(S_n\) is binomially distributed, \(S_n \sim B (n, 1 / 2)\). The number of kids until the numbers of boys and girls are equal is \[ T = \min \{n : S_n = n / 2\} \] which is a simple example of what is called a stopping time in financial mathematics. The expected size of our family is thus the expected value \(E(T)\).

To calculate \(E(T)\) we set out to obtain the probabilities \(P (T = 2 n)\) first. It's a nice exercise to try and do this! As a hint, you could count the number of ways that you can have \(2 n\) kids (\(n\) of them girls and the other \(n\) boys) in such a way that at no time \(m \leqslant 2 n\) the numbers of girls and boys matches. Each such configuration can be visualized as follows: start at the point \((0, 0)\) in the \(x\)-\(y\) plane and move a step to the right if the first kid is a girl or a step up if it is a boy. By repeating to make steps in this manner for the second, third, etc. child you will end up at \((n, n)\) after the \(2 n\) kids. The condition that the numbers of girls and boys matches only at the end translates into your path staying strictly either below or above the diagonal. With this picture in mind, we remind ourselves that the number of right-up paths from \((0, 0)\) to \((n, n)\) which stay strictly below the diagonal is given by the Catalan number \(C_{n - 1} = \frac{1}{n} \binom{2 (n - 1)}{n - 1}\). Since the total number of ways to get \(2 n\) kids is \(2^{2 n}\) we thus found: \[ P (T = 2 n) = \frac{2 \cdot C_{n - 1}}{2^{2 n}} \]

## Might \(T\) be infinite?

Notice that besides taking a value like \(2 n\) the variable \(T\) may be infinite (for instance if you always have more girls than boys). But that doesn't seem very likely, does it? In fact, we can now deduce this missing probability: \[ P (T = \infty) = 1 - \sum_{n = 1}^{\infty} P (T = 2 n) = 1 - \sum_{n = 0}^{\infty} \frac{1}{(2 n) 2^{2 n}} \binom{2 n}{n} = 0. \]

## The expected value

It follows that \[ E (T) = \sum_{n = 1}^{\infty} 2 n \cdot P (T = 2 n) = \sum_{n = 0}^{\infty} \frac{1}{2^{2 n}} \binom{2 n}{n} = \infty \] which diverges because the summand grows like \(n^{- 1 / 2}\) (a well-known consequence of Stirling's formula).

## One-dimensional random walks

One can interpret the bearing of children as a one-dimensional random walk starting at \(0\), a girl corresponding to a step left and a boy to a step right. This is a slight variation on the model presented above. If we let \(Y_k = 2 X_k - 1\) with \(X_k\) as before (in other words, \(Y_k\) is \(1\) if the \(k\)th kid is a girl and \(- 1\) otherwise) then the walk at time \(n\) is at position \(W_n = \sum_{k = 1}^n Y_k\).

With this interpretation, the question of having an equal number of boys and girls translates into asking for the recurrence of the walk to the origin. The probability \(P (T = 2 n)\) that we computed above is the probability that the walk for the first time returns to the origin at time \(2 n\). In particular, \(P (T < \infty) = 1\) sums up the well-known fact that a one-dimensional walk is recurrent, that is, it returns to the origin at least once with probability \(1\). This is a classical result by Pólya who also showed that similar two-dimensional lattice walks are recurrent, while starting with three dimensions such walks are transient meaning that there is a nonzero chance that the walk will never return to the origin. This is nicely expressed by the quote

A drunk man will find his way home, but a drunk bird may get lost forever.

which is usually attributed to Shizuo Kakutani.## More general one-dimensional random walks

Let's consider a variation on the original problem by dropping the assumption that girls and boys are equally likely. In the notation of the previous paragraph, we write \(p = P (Y_k = 1)\) for the probability to get a girl (then \(1 - p\) is the probability for a baby boy). \(T\) still defined as before, the same argument shows that now \[ P (T = 2 n) = 2 \cdot C_{n - 1} \cdot p^n (1 - p)^n . \] It is not surprising that there is now a positive probability that \(T\) will be infinite (think of an extreme case where there is just a, say, 1% probability for boys). In fact, we find \[ P (T < \infty) = \sum_{n = 1}^{\infty} P (T = 2 n) = 2 \sum_{n = 0}^{\infty} C_n p^{n + 1} (1 - p)^{n + 1} = 1 - \sqrt{1 - 4 p (1 - p)} = 1 - 2 \left| p - \frac{1}{2} \right| \] which follows from the very well-known generating function \[ \sum_{n = 0}^{\infty} C_n x^n = \frac{1 - \sqrt{1 - 4 x}}{2 x} \] of the Catalan numbers.

In particular, for \(p \neq 1 / 2\) there is always a positive probability that a random walk will never return to the origin. Surprisingly (at least to me), this probability is just given by \(2| p - 1 / 2|\) which is precisely the difference between \(p\) and \(1 - p\).

## A personal surprise

Even more surprisingly, I was recently contacted by Xu Xin-Ping from Suzhou University about a combinatorial identity which I was able to prove using creative telescoping. When I later read the resulting manuscript, it turned out that this identity is used precisely to deduce the above probability \(P (T < \infty)\), which is also known as the Pólya number of the associated random walk. The surprise here was that I read the manuscript on the evening *after* the above findings and discussions with James. How likely is that?

As a final remark, the authors of the manuscript consider a more general random walk by allowing it to also rest at a given position (besides going left or right) which curiously corresponds to the possibility of intersex babies. However, this apparent generalization clearly has no effect on the Pólya number of the associated walk (just ignore the rests—they are not impacting whether you will eventually come back to the origin or not; it may just take longer).