You may have noticed, but I have been on a brainteaser kick; I blame it on reading online on how to prepare for interviews–I’m trying to get a job! I found this probability question on Quora.

Suppose your wife is at the hospital, and she’s just given birth to a health baby; but you do not know if it’s a boy or girl. The baby has been taken to the hospital nursery, where before the addition of your infant, there are $2$ boys and an unknown (but fixed) number of girls $n\in\mathbb{N}$. The nurse selects an infant at random from the nursery. Given that the nurse’s selection is a boy, what is the probability that your wife gave birth to a boy?

Proof. The problem can be solved with Bayes’ theorem. Let $I_{1}$ and $I_{2}$ be the Bernoulli random variables representing the sex of your baby and the sex of the baby the nurse picks up from the nursery, respectively. We assume that a woman is equally likely to have a boy as a girl, so $\mathbb{P}(I_{1}=1)=\mathbb{P}(I_{1}=0)=\frac{1}{2}$. We are interested in the probability that $I_{1}=1$ given $I_{2}=1$, which we write as

$\displaystyle\mathbb{P}(I_{1}=1\mid I_{2}=1)$

By Bayes’ theorem,

$\displaystyle\mathbb{P}(I_{1}=1\mid I_{2}=1)=\frac{\mathbb{P}(I_{2}=1\mid I_{1}=1)\mathbb{P}(I_{1}=1)}{\mathbb{P}(I_{2}=1)}=\frac{1}{2}\frac{\mathbb{P}(I_{2}=1\mid I_{1}=1)}{\mathbb{P}(I_{2}=1)}$

There are $n$ girls and $3$ boys in the nursery, if the wife has a boy. Since we assume that each infant in the nursery has equal probability of being selected by the nurse, we see that

$\displaystyle\mathbb{P}(I_{2}=1\mid I_{1}=1)=\frac{3}{n+3}$

To compute $\mathbb{P}(I_{2}=1)$, we condition on $I_{1}$, obtaining

$\begin{array}{lcl}\displaystyle\mathbb{P}(I_{2}=1)&=&\displaystyle\mathbb{P}(I_{2}=1\mid I_{1}=1)\mathbb{P}(I_{1}=1)+\mathbb{P}(I_{2}=1\mid I_{1}=0)\mathbb{P}(I_{1}=0)\\[.7 em]&=&\displaystyle\frac{1}{2}\left[\mathbb{P}(I_{2}=1\mid I_{1}=1)+\mathbb{P}(I_{2}=1\mid I_{1}=0)\right]\\[.7 em]&=&\displaystyle\frac{1}{2}\left[\frac{3}{n+3}+\frac{2}{n+3}\right]\\[.7 em]&=&\displaystyle\frac{5}{2(n+3)}\end{array}$

Substituting these results in, we obtain

$\displaystyle\mathbb{P}(I_{1}=1\mid I_{2}=1)=\frac{1}{2}\dfrac{\frac{3}{n+3}}{\frac{5}{2(n+3)}}=\dfrac{3}{5}$

Your wife had a boy with probability $\frac{3}{5}$, given the information that the nurse selected a boy at random from the nursery.