Coffeehouse Post

Single Post Permalink

View Thread: 100%
  • User profile image
    Sven Groot

    Sven Groot said:
    Dr Herbie said:
    *snip*
    It depends on how you interpret the question.

    If you interpret the question as: my first child is a girl. Now my wife is pregnant, what are the odds of the other one being a boy? Then it's 50%.

    However, if you interpret it as: we already have two children, one of whom is a girl. How likely is it that the other is a boy? Then we must consider the following: the likelyhood of having two boys is 50% * 50% = 25%. The likelyhood of having two girls is also 50% * 50% = 25%. The likelyhood of having a boy and a girl is 50% * 50% + 50% * 50% = 50%.
    With the added information that one child is a girl, we know that two boys are impossible. We are therefore left with either boy and girl at 66% or two girls at 33%. So in 66% of the remaining scenarios, the second child is a boy.

    The disagreement people are having is one of semantics, not maths.
    Here's experimental validation of the second interpretation:


    const int runs = 10000000;
    Random rnd = new Random();
    int[] children = new int[2];
    int twoGirls = 0;
    int boyGirl = 0;
    for( int x = 0; x < runs; ++x )
    {
    // 1 = boy, 2 = girl
    children[0] = rnd.Next(1, 3); // 1 or 2
    children[1] = rnd.Next(1, 3);

    // We're ignoring the two boy situation.
    if( !(children[0] == 1 && children[1] == 1) )
    {
    if( children[0] == 2 && children[1] == 2 )
    twoGirls++;
    else
    boyGirl++;
    }
    }

    Console.WriteLine("Two girls: {0}%", twoGirls / (float)(twoGirls + boyGirl) * 100);
    Console.WriteLine("Boy/girl: {0}%", boyGirl / (float)(twoGirls + boyGirl) * 100);


    That prints:
    Two girls: 33,3692%
    Boy/girl: 66,6308%

    Or numbers close to that (obviously it won't be exactly the same every time). Smiley