# Simple Bayes Theorem question

You know there are 3 boys and an unknown number of girls in a nursery at a hospital. Then a woman gives birth a baby, but you do not know its gender, and it is placed in the nursery. Then a nurse comes in a picks up a baby and it is a boy. Given that the nurse picks up a boy, what is the probability that the woman gave birth to a boy?

So I've narrowed it down (taking the number of girls to be $n$) to:

\begin{align*} &P(\text{woman had a boy} \mid \text{nurse picked up boy)}\\ &\qquad= \frac{P(\text{nurse picked up boy} \mid \text{woman had a boy}) P(\text{woman had boy})}{P(\text{nurse picked up boy})}\\ &\qquad=\frac{\frac{4}{(4+n)}\cdot0.5}{3/(3+n)}\;, \end{align*}

but there's no way for me to get an analytical answer that makes sense. The correct answer is $\frac{4}{7}$.

Your denominator would be $P(\text{nurse picked up a boy})$ before the new baby was ever born. You need the probability that the nurse picked up a boy marginalized across both genders that the new baby could be, which is to say $$.5\frac{3}{4+n}+.5\frac{4}{4+n}$$ This should be the denominator since there are definitely $4+n$ children in the nursery now, and either $3$ or $4$ of them are boys.

Now to get $4/7$ is just to cancel the $.5/4+n$ from numerator and denominator.

Let $E_1$ and $E_2$ be two events defined as

$E_1:$ boy is born

$E_2:$ girl is born

Let say that initially there were $n$ girls.

$B:$ boy picked up by nurse

$G:$ girl picked up by nurse

$P(E_1|B)=\frac{P(E_1)P(B|E_1)}{P(E_1)P(B|E_1)+P(E_2)P(B|E_2)}=\frac{\frac{1}{2}\frac{4}{4+n}}{\frac{1}{2}\frac{4}{4+n}+\frac{1}{2}\frac{3}{4+n}}=\frac{2}{2+\frac{3}{2}}=\frac{2}{\frac{7}{2}}=\frac{4}{7}$

We have a number of girls, $$g$$, and a number of boys, $$b$$, when another child is born. The a priori probability of that child being either a boy or a girl is 50%. $$P(C_b) = 1 - P(C_g) = \tfrac{1}{2}$$

The probability of the nurse picking up a boy if the new born child was a boy, $$P(S_b|C_b)$$, and the probability of the nurse picking up a boy if the new born child was a girl, $$P(S_b|C_g)$$, are $$P(S_b|C_b) = \frac{b+1}{b+1+g}$$ and $$P(S_b|C_g) = \frac{b}{b+1+g}$$

The probability of the nurse picking up a boy, $$P(S_b)$$, is the sum of the probabilities that the child is either a boy or a girl and the accompanying probability of the nurse picking up a boy in that case. $$P(S_b) = P(S_b|C_b) + P(S_b|C_g) = \tfrac{1}{2} \cdot \frac{b+1}{b+1+g} + \tfrac{1}{2} \cdot \frac{b}{b+1+g} = \tfrac{1}{2} \cdot \frac{2b+1}{b+1+g}$$

Now the chance that the new born child is a boy given that the nurse picked up a boy, $$P(C_b|S_b)$$, is as follows, as per Bayes' theorem:

$$P(C_b|S_b) = \frac{P(C_b) \cdot P(S_b|C_b)}{P(S_b)} = \frac{\frac{1}{2} \cdot \frac{b+1}{b+1+g}}{\tfrac{1}{2} \cdot \frac{2b+1}{b+1+g}} = \frac{b+1}{2b+1}$$

You may have noticed that the number of girls neatly cancelled out of the equation.

If we plug in the specific number of boys already born, in this case $$3$$, we get $$P(C_b|S_b) = \frac{b+1}{2b+1} = \frac{3+1}{2 \cdot 3 +1} = \frac{4}{7}$$

QED

‡: In the real world, the ratio boys to girls isn't exactly 1:1, but in these kind of questions, it always is.