Jump to content

Welcome to BrainDen.com - Brain Teasers Forum

Welcome to BrainDen.com - Brain Teasers Forum. Like most online communities you must register to post in our community, but don't worry this is a simple free process. To be a part of BrainDen Forums you may create a new account or sign in if you already have an account.
As a member you could start new topics, reply to others, subscribe to topics/forums to get automatic updates, get your own profile and make new friends.

Of course, you can also enjoy our collection of amazing optical illusions and cool math games.

If you like our site, you may support us by simply clicking Google "+1" or Facebook "Like" buttons at the top.
If you have a website, we would appreciate a little link to BrainDen.

Thanks and enjoy the Den :-)
Guest Message by DevFuse


Member Since 10 Jul 2012
Offline Last Active Jul 19 2012 08:52 PM

#321867 One Girl - One Boy

Posted by syonidv on 10 July 2012 - 08:51 PM

Wow, I was a doubter, but I have to say I'm impressed. The question I will ask all of you, before all of your bickering and mathematics, is have you tried it out? I wrote a simple program to chuck out the numbers, and the results are pretty astounding.

Your simulation is flawed, specifically at the point where you query
if( family.Child1 || family.Child2 )

The 'or' condition encapsulates the condition that the family has at least one girl, but it does not encapsulate the restriction that once a girl has been observed, we need to definitively assign this girl as "sibling #1" or "sibling #2".

Consider the corrected code, which honours the constraint that the observed child must be either child 1 or child 2 (I wrote it in javascript, and you can run it by simply pasting it into a site such as this one:

(function() {
    var BOY = 0, GIRL = 1;
    var FIRST = 0, SECOND = 1;

    var second_girls = 0, second_boys = 0;

    for( var i = 0; i < 100000; i++ ) {
        var family = {
            child1: Math.random() < 0.5 ? BOY : GIRL,
            child2: Math.random() < 0.5 ? BOY : GIRL

        var child_we_happen_to_see = Math.random() < 0.5 ? FIRST : SECOND;
        var gender_of_child_we_see = (child_we_happen_to_see == FIRST) ? family.child1 : family.child2;

        if( gender_of_child_we_see == BOY )
            continue; /* this is our conditioning; omit any trial where a boy is observed */

        var gender_of_other_child = (child_we_happen_to_see == FIRST) ? family.child2 : family.child1;
        if( gender_of_other_child == BOY )
        else second_girls++;

    alert( "Number of boys is " + second_boys + ".\n" +
        "Number of girls is " + second_girls + ". This is " +
        (new Number( 100*second_girls/(second_girls + second_boys))).toFixed( 2 ) + '%.' );

In my run, I get "Number of boys is 25020. Number of girls is 24799. This is 49.78%."

This makes intuitive sense. The number of included trials is approx. 50,000--all those cases where we happened upon a family and happened to observe a girl child with them. And of those families, approximately half have a boy as the second child.

I believe somebody mentioned this earlier, but an excellent analog that helps make sense of "why you need to constrain the observed child to either child 1 or child 2" is called the "Gambler's Ruin" problem.

Consider I have two boxes, A and B. I tell you that there is some non-zero amount of money in the boxes, and that one box contains exactly twice the amount of money as the other one. But I don't tell you which one is which.

Suppose you pick box A. It has some unknown amount of money, X, in it. But then you think: wait a minute, there's a 50% chance that box B has twice as much money, or 2X, and a 50% chance that it has half as much money, or X/2. So if we calculate the expected value for the amount of money in box B we get

E(B) = 0.5*(2X) + 0.5*(X/2) = 1.25X

Or, roughly 25% more money than in box A. So we decide to swap. But now we let our (slightly larger) amount of money be X and the same logic applies to swapping back to box A.

Hence, by simply swapping A with B again and again, we can make our amount of money grow to infinity! We're rich! :D

Of course, we can disprove this fallacy by honouring the "our box must be only one of either A or B" constraint. That is, the calculation

E(B) = 0.5*(2X) + 0.5*(X/2)

assumes that the box we're holding is in a fuzzy state of simultaneously being both the greater AND the lesser money box (X/2 is only valid if the former is true, and 2X is only valid if the latter is true).

In the same way, "if( family.Child1 || family.Child2 )" assumes the child we've observed is in a fuzzy state of simultaneously being both the first AND second child. But it has to be one or the other.
  • 1

#321745 One Girl - One Boy

Posted by syonidv on 10 July 2012 - 01:05 AM

Let mine be one more vote for itsclueless's correct (also, rational :P ) answer. The probability of the "other child" being a girl is 1/2.

The answer offered by brainden.com is incorrect, and even the cusory consideration that observing one sibling changes the probability of the other's gender should set off red flags in people's minds.

The proof that I give to people is as follows:

The two facts we know are:

two children have been born (fact A)
at least child is female (fact B)

Fact A gives us the four possible populations (male/female configurations):


It then also seems logical to eliminate any combination where at least one female is not present (i.e. M-M), leaving,


and then concluding a 67% probability of 2M and 1F. The problem is that these three remaining combinations are not equally likely. That is, we've botched the application of Bayes' rule.

The correct approach is to start with as our four equally-likely populations:


We now sample randomly from one of these four possible populations. We sample a 'F'. (This sampling process is completely equivalent to the statement "there is at least one female in the population". No more and no less information is gained.)

Since we know the a priori probabilities of each of the four configurations (populations) and the probability of sampling an F given each configuration, Bayes' rule tells us what the (conditional) probability of each configuration is after we've observed an 'F'.

I turns out that prob( M-M ) = 0, as expected (i.e. you can't sample a male from female-only population), but for the remaining three,

prob( M-F ) = 1/4
prob( F-M ) = 1/4
prob( F-F ) = 1/2

Or stated more intuitively: the fact that we sampled a female member gives us a higher probability that we sampled it from a female-rich population. In this case, the probability of the F-F config is exactly the same as the combined probabilities of the F-M and M-F configs, giving 50%/50% as expected.

Hence, to summarize, we started out with four populations of equal a priori probability:

M-M : probability 1/4
M-F : probability 1/4
F-M : probability 1/4
F-F : probability 1/4

We observed that at least one of the two children is female, which, through a straightforward application of Bayes' rule, yields our post-observation probabilities:

M-M : probability 0
M-F : probability 1/4
F-M : probability 1/4
F-F : probability 1/2

In configurations 2 and 3, the "other child" is always male. In configuration 4 (which is twice as likely given our observation), the "other child" is always female. Hence:

probability( second child is male ) = 1/4 + 1/4 = 1/2
probability( second child is female ) = 1/2 = 1/2

  • 1