family_probs maps a number of children to the proportion of families with
that many, for example {1: 0.3, 2: 0.5, 3: 0.2}. Each child is a girl
independently with probability p_girl. Pick a girl uniformly at random from
all the girls in the population, and return the probability she has at least one
sister.
The trap is sampling: you are choosing a girl, not a family, so a family with more girls is proportionally more likely to be the one you landed in.
k children contributes girls in proportion to family_probs[k] * kk - 1 children are still independentInput
family_probs = {1: 0.3, 2: 0.5, 3: 0.2}
p_girl = 0.5
Output
0.5