### Tuesday Boy Problem Solved by Simulation

The other day, I came across a logic/math problem I hadn't heard before, The Tuesday Birthday Problem. It goes like this:

I have two children, one of whom is a son born on a Tuesday. What is the probability that I have two boys?

This puzzle was apparently first presented at a convention for mathematicians, magicians and puzzle enthusiasts (yeah, that's a pretty specialized convention) by Gary Foshee. Immediately after giving the puzzle, he followed up with this.

The first thing you think is 'What has Tuesday got to do with it?' Well, it has everything to do with it.

I know my first inclination was to dismiss that extra fact. How could it have any effect on the probability of the sex of the other child. I first read this puzzle late at night when I was tired, so I didn't feel like putting too much thought into it. Instead, I just read the explanations of how that extra bit of information alters the odds. But I still wasn't ready to buy those explanations just yet. But rather than try to think through the explanation that night, I decided to tackle it from a different angle. Instead of trying to figure out the odds, I'd just program a simulation and see how it played out.

In fact, this is a very simple simulation. I didn't program it in the most efficient manner, but it got the job done. Here's what I did. I created a 4 x 10,000 element array. That is, 10,000 sets of kids, with four pieces of information to designate sex and birth day of the week for each kid (sex 1, day 1, sex 2, day 2). Then, I randomly assigned sex and birth day to each of the kids. Next, I created a couple variables that would be filled in in the next stage. First was a variable keeping track of the number of sets where at least one was a boy born on a Tuesday - that is, the number of sets where the father would have given his first statement. The other variable was the number of sets with a boy born on a Tuesday and another son - the sets fulfilling the second statement. With the array and variables in place, I went back and did some if statements to simulate the father's conditions, increasing the totals of those variables as appropriate. When that was done, I simple divided the number of sets with kids with a boy born on a Tuesday and another son by the number of sets with at least one boy born on a Tuesday.

After running this program a few times, I found a small problem. 10,000 sets wasn't enough. The fraction was varying by several percentage points each time I ran it. So, I added one more feature to allow the program to keep a running average every time it ran.

Oh, and just to be sure I was doing things properly, I added a similar set of calculations to calculate the probability for a simpler puzzle:

I have two children, one of whom is a son. What is the probability that I have two boys?

This is much easier to understand, so it was my control to make sure the algorithm was working properly.

**Warning: Don't read on if you want to solve the problem on your own, first.**

Well, guess what I found out. After running the simulation on 100,000,000 sets of kids, I got a probability of 0.4813391 for the Tuesday boy problem, and 0.3333046 for the simpler boy problem. Those are very close to the actual odds of 13/27 (0.481481481...) and 1/3 (0.33333333...). It's pretty counterintuitive, but I guess those eggheads know what they're talking about, after all.

*Image Source: Wikimedia Commons*

Anyone interested in checking this out for themselves can download my program below: