# Family Size

What is the average number of children a family must have to guarantee at least
two of each gender? This is obviously not something that you can go out and
practice since a good average requires a large sample size.

Logic and common sense would tell us the answer is at least four. You can't
have at least two boys and two girls until you have four children. But the answer
is not that simple. Do you know of any families that have more than four kids
but not at least two boys and two girls? I do, my grandparents had eight kids
before there were two boys (ultimately ending up with nine kids). So while the
simple answer is "at least four", we need something a little bit more
precise.

## Type of Simulation

What we're asked to do here is to find an average. When this is the case, we
conduct an experiment (simulated or real) until conclusion and record how long
it takes until completion. We repeat this process over and over (the more times
the better) and when we are done simulating or experimenting, we find the mean
of all those trials.

This is not a simulation where you record the outcomes as success or failure.
This is a situation that is played until completion, so ultimately, everything
would be a success. We're looking for the expected number of children before
there are at least two boys and two girls.

## Sample Families

This simulation could be done easily with a coin. Assign heads to men and tails
to women (or vice versa) and flip until you have at least two heads and two
tails. Record the number of trials it took to do that and then repeat the process.
When you've repeated the process many times, then find the average.

Let's look at a few trials so we can see how this would work.

**Family 1**
- H H T T
** =** B B G G

4 kids
**Family 2**
- T H T T H = G B G G B

5 kids
**Family 3**
- T T T H H = G G G B B

5 kids
**Family 4**
- H T H H H H T = B G B B B B G

7 kids

You would then find the average of those families ( 4 + 5 + 5 + 7 ) / 4 = 5.25
and we would say the average number of children required to have at least two
of each gender is 5.25.

Of course, four trials is really too small of a sample size.

## The Simulation

This problem can also be simulated with a computer. Generate random numbers
that stand for boy or girl. Let's let 0 represent a boy and 1 represent a girl.

Enter the number of people in the room and then hit the simulate button. Repeat
the process several times with the same sample size to get an approximation.

Return to Simulation Page