The Wiki article you reference in your own code explains it well. The problem is in the assumptions made by the person answering a riddle. Just because you have a child, and it's a boy, and he is born on Tuesday, it does not mean that your next child is more likely to be a girl. If you agree with that statement, then the original answer must be false.
In the problem I pose, the person does not randomly come forward and tell me "I have a boy born on a tuesday". In my problem I ask random people who I know have two children if they have "at least on boy born on a tuesday" until someone says yes.
girl = 0
boy = 0
do 10000 times {
child1Sex = randomSex;
child1Day = randomDay;
child2Sex = randomSex;
child2Day = randomDay;
if ( (child1Sex == "B" AND child1Day == "Tu") OR (child2Sex == "B" AND child2Day == "Tu") ) {
if (child1Sex == child2Sex){
boy++
} else {
girl++
}
}
}
print "Ratio of boys and girls is " + boy " : " + girl;It is the most counter-intuitive statistic problem I know (worse than Monty Hall), it trips everyone up at first.
No problem about the stubborness ;)
the range(0,10000) may not be correct, it might need to be 1,10000
This is really counter intuitive, the open vs. closed probability set through me off. Hey, thanks for putting up with my stubbornness!
Try something easier, for example two dice. The probability to roll 1 1 is less than to roll 1 2, because 1 2 can be rolled either by first rolling a 1 or a 2, while 1 1 can be rolled only by first rolling a 1. That information is used often in dice games like backgammon.
Same with children: BT BT can only be "rolled" if your first child is BT, whil BT BW can be "rolled" if your first child is either BT or BW.
Do you see?