Re:Online executable Python solution to the Tuesday boy problem
by x0054 on Friday January 10, 2014 @09:47PM
(#7041260)
My python is really rusty, but if you convert this sudocode to python, you will see that the answer is 50/50. I'll write this up in Javascript when I have time. If you do this in Python, please post.
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;
Re:Online executable Python solution to the Tuesday boy problem
by daivd on Saturday January 11, 2014 @04:58AM
(#7042187)
I whipped together something here, before I saw that someone else did it too: http://ideone.com/jyPOhs
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 ;)
Re:Online executable Python solution to the Tuesday boy problem
by krapp on Friday January 10, 2014 @10:08PM
(#7041327)
Here's my attempt in python: http://pastebin.com/tSDK1uRv
the range(0,10000) may not be correct, it might need to be 1,10000
Re:Online executable Python solution to the Tuesday boy problem
by x0054 on Saturday January 11, 2014 @04:40AM
(#7042156)
Wow, works good. I should learn python :) But yeah, you were absolutely right! It was hard for me to figure out because I was trying to find a mathematical reason for this, and I was wrong. I finally figured it out mathematically. The way you posit the problem the probability that the asked parents have another boy is (1/2)-(1/7/2).
This is really counter intuitive, the open vs. closed probability set through me off. Hey, thanks for putting up with my stubbornness!
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.