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 )
second_boys++;
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!
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.