{"id":489,"date":"2012-10-01T01:00:00","date_gmt":"2012-09-30T23:00:00","guid":{"rendered":"https:\/\/www.fussylogic.co.uk\/blog\/?p=489"},"modified":"2012-11-17T10:44:02","modified_gmt":"2012-11-17T10:44:02","slug":"child-gender-ratios","status":"publish","type":"post","link":"https:\/\/www.fussylogic.co.uk\/blog\/?p=489","title":{"rendered":"Child Gender Ratios"},"content":{"rendered":"<blockquote>\n<p>There\u00e2\u20ac\u2122s a country where everybody wants to have a son. Therefore each couple keeps having children until they have a boy; then they stop. What fraction of the population is female? (You may assume the question is asked as an expectation of course, since any particular country can be anything in principle \u00e2\u20ac\u201d 100% girls is possible, just not likely)<\/p>\n<\/blockquote>\n<p>It\u00e2\u20ac\u2122s (reportedly) asked as one of the Google interview questions.<\/p>\n<p>The non-mathematician can\u00e2\u20ac\u2122t tell you the answer, but believes that the above policy results in more boys. They\u00e2\u20ac\u2122re wrong (well, ish, for practical purposes it\u00e2\u20ac\u2122s good enough). This answer is exactly what (reportedly) Google expect:<\/p>\n<blockquote>\n<p>Assuming a random arrival pattern of boys and girls: &#8211; half of all couples will have a boy as their first child and that is the end of that. &#8211; if the other half, who\u00e2\u20ac\u2122ve had a girl, try again, half of them will go on to have a boy and half will go on to have another girl.<\/p>\n<p>So out of 100 couples, we end up with: &#8211; 50 having one boy = 50 boys &#8211; 25 having one girl and one boy = 25 girls and 25 boys &#8211; 25 having two girls = 50 girls<\/p>\n<\/blockquote>\n<p>\u00e2\u20ac\u00a6 and so on.<\/p>\n<p>The logic is good (and it is the logic I had remembered for a long time). It basically says: \u00e2\u20ac\u0153any given birth has a 50% chance of being a girl\u00e2\u20ac\u009d, therefore the number of girls in the country will be <code>number of births * 0.5<\/code>; hence the fraction of the population that is female is 50%. Regardless of stopping criteria.<\/p>\n<p>It took repeated reads of <a href=\"http:\/\/www.thebigquestions.com\/2010\/12\/22\/a-big-answer-2\/\">Steve Landsburg\u00e2\u20ac\u2122s blog<\/a> to convince me that even this, cleverer, answer is not correct either.<\/p>\n<p>The faulty assumption in the above analysis is shown by this fact:<\/p>\n<p><math display=\"inline\" xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"><mrow><mfrac><mrow><mi>E<\/mi><mo stretchy=\"false\">[<\/mo><mi>G<\/mi><mo stretchy=\"false\">]<\/mo><\/mrow><mrow><mi>E<\/mi><mo stretchy=\"false\">[<\/mo><mi>G<\/mi><mo>+<\/mo><mi>B<\/mi><mo stretchy=\"false\">]<\/mo><\/mrow><\/mfrac><mo>&#8800;<\/mo><mi>E<\/mi><mo stretchy=\"false\">[<\/mo><mfrac><mi>G<\/mi><mrow><mi>G<\/mi><mo>+<\/mo><mi>B<\/mi><\/mrow><\/mfrac><mo stretchy=\"false\">]<\/mo><\/mrow><\/math>\n<\/p>\n<p>(<\/p>\n<math display=\"inline\" xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"><mrow><mi>E<\/mi><mo stretchy=\"false\">[<\/mo><mo>&#8901;<\/mo><mo stretchy=\"false\">]<\/mo><\/mrow><\/math>\n<p> being the <em><a href=\"http:\/\/en.wikipedia.org\/wiki\/Expected_value\">expectation operator<\/a><\/em>.) That is to say that the expectation of a ratio is not necessarily equal to the ratio of the expectations.<\/p>\n<p>The error is made by calculating the expectation over all arrangements of individuals instead of over all arrangements of countries.<\/p>\n<p>We\u00e2\u20ac\u2122ll first answer a simpler question by considering a country with only one family. We calculate expectation over all possible one family countries. The possible arrangements of children in that one family country are:<\/p>\n<pre><code>N  children   % girls     likelihood\n-----------------------------------------------------------\n0  B             0%        0.5\n1  GB           50%        0.5 * 0.5\n2  GGB          66%        0.5 * 0.5 * 0.5\n3  GGGB         75%        0.5 * 0.5 * 0.5 * 0.5\n4  GGGGB        80%        0.5 * 0.5 * 0.5 * 0.5 * 0.5\n5  GGGGGB       83%        0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5\n... etc ...\nn  nG+B        n\/(n+1)     0.5^(n+1)\n<\/code><\/pre>\n<p>Remember that expected value is the sum of values multiplied by the probability of that value. So for the specific case of the one family country, we are simply summing up the product of columns three and four in the above table:<\/p>\n<p><math display=\"inline\" xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"><mrow><msub><mi>E<\/mi><mn>1<\/mn><\/msub><mo stretchy=\"false\">[<\/mo><mfrac><mi>G<\/mi><mrow><mi>G<\/mi><mo>+<\/mo><mi>B<\/mi><\/mrow><\/mfrac><mo stretchy=\"false\">]<\/mo><mo>=<\/mo><munderover><mo>&#8721;<\/mo><mrow><mi>n<\/mi><mo>=<\/mo><mn>0<\/mn><\/mrow><mo>&#8734;<\/mo><\/munderover><mrow><mfrac><mn>1<\/mn><msup><mn>2<\/mn><mrow><mi>n<\/mi><mo>+<\/mo><mn>1<\/mn><\/mrow><\/msup><\/mfrac><mfrac><mi>n<\/mi><mrow><mi>n<\/mi><mo>+<\/mo><mn>1<\/mn><\/mrow><\/mfrac><\/mrow><\/mrow><\/math>\n<\/p>\n<p>Fortunately this is a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Series_%28mathematics%29\">convergent series<\/a>, so has a real answer (which the <a href=\"http:\/\/mathoverflow.net\/questions\/17960\/google-question-in-a-country-in-which-people-only-want-boys\">mathoverflow link<\/a> tells me is):<\/p>\n<p><math display=\"inline\" xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"><mrow><mn>1<\/mn><mo>&#8211;<\/mo><mi>ln<\/mi><mo stretchy=\"false\">(<\/mo><mn>2<\/mn><mo stretchy=\"false\">)<\/mo><mo>=<\/mo><mn>30<\/mn><mo>.<\/mo><mn>69<\/mn><\/mrow><\/math>\n<\/p>\n<p>This should already be sufficient to convince you of the difference between the expectation of a ratio, and the ratio of expectations.<\/p>\n<p>We can do the same for countries with two families; although it gets horrible looking pretty quickly:<\/p>\n<pre><code>children       % girls     likelihood\n------------------------------------------------------------\nB \/ B            0%        (0.5) * (0.5)\nB \/ GB          33%        (0.5) * (0.5 * 0.5)\nB \/ GGB         50%        (0.5) * (0.5 * 0.5 * 0.5)\nB \/ GGGB        60%        (0.5) * (0.5 * 0.5 * 0.5 * 0.5)\nB \/ GGGGB       66%        (0.5) * (0.5 * 0.5 * 0.5 * 0.5 * 0.5)\nB \/ GGGGGB      71%        (0.5) * (0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5)\n ... etc ...\nGB \/ B          33%        (0.5 * 0.5) * (0.5)\nGB \/ GB         50%        (0.5 * 0.5) * (0.5 * 0.5)\nGB \/ GGB        60%        (0.5 * 0.5) * (0.5 * 0.5 * 0.5)\nGB \/ GGGB       66%        (0.5 * 0.5) * (0.5 * 0.5 * 0.5 * 0.5)\nGB \/ GGGGB      71%        (0.5 * 0.5) * (0.5 * 0.5 * 0.5 * 0.5 * 0.5)\nGB \/ GGGGGB     75%        (0.5 * 0.5) * (0.5 * 0.5 * 0.5 * 0.5 * 0.5 * 0.5)\n ... etc ...\n<\/code><\/pre>\n<p>Yuck. Regardless of how nasty this is getting, the expectation for two families is:<\/p>\n<p><math display=\"inline\" xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"><mrow><msub><mi>E<\/mi><mn>2<\/mn><\/msub><mo stretchy=\"false\">[<\/mo><mfrac><mi>G<\/mi><mrow><mi>G<\/mi><mo>+<\/mo><mi>B<\/mi><\/mrow><\/mfrac><mo stretchy=\"false\">]<\/mo><mo>=<\/mo><munderover><mo>&#8721;<\/mo><mrow><mi>n<\/mi><mo>=<\/mo><mn>0<\/mn><\/mrow><mo>&#8734;<\/mo><\/munderover><mrow><mfrac><mrow><mi>n<\/mi><mo>+<\/mo><mn>1<\/mn><\/mrow><msup><mn>2<\/mn><mrow><mi>n<\/mi><mo>+<\/mo><mn>2<\/mn><\/mrow><\/msup><\/mfrac><mfrac><mi>n<\/mi><mrow><mi>n<\/mi><mo>+<\/mo><mn>2<\/mn><\/mrow><\/mfrac><\/mrow><\/mrow><\/math>\n<\/p>\n<p>I\u00e2\u20ac\u2122m afraid, that the mathoverflow article loses me then; as I have never heard of the \u00e2\u20ac\u0153digamma function\u00e2\u20ac\u009d it talks about. I can see what it\u00e2\u20ac\u2122s doing though \u00e2\u20ac\u201d it\u00e2\u20ac\u2122s simply a way of converting the infinite sum expression into a direct equation.<\/p>\n<p>Leaving that nightmare to the real mathematicians, for our purposes all we care about is that <\/p>\n<math display=\"inline\" xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"><mrow><msub><mi>E<\/mi><mi>k<\/mi><\/msub><mo stretchy=\"false\">[<\/mo><mfrac><mi>G<\/mi><mrow><mi>G<\/mi><mo>+<\/mo><mi>B<\/mi><\/mrow><\/mfrac><mo stretchy=\"false\">]<\/mo><mo>&#8594;<\/mo><mfrac><mn>1<\/mn><mn>2<\/mn><\/mfrac><mo>&#8211;<\/mo><mfrac><mn>1<\/mn><mrow><mn>4<\/mn><mi>k<\/mi><\/mrow><\/mfrac><mo>&#8594;<\/mo><mn>50<\/mn><mo>%<\/mo><\/mrow><\/math>\n<p> as <\/p>\n<math display=\"inline\" xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"><mrow><mi>k<\/mi><mo>&#8594;<\/mo><mo>&#8734;<\/mo><\/mrow><\/math>\n<p>. Importantly though: it never quite reaches it.<\/p>\n<p>Executive summary: <strong>The expected percentage of girls in a country of <\/p>\n<math display=\"inline\" xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"><mrow><mi>k<\/mi><\/mrow><\/math>\n<p> families, operating the \u00e2\u20ac\u0153stop on boy\u00e2\u20ac\u009d policy, is less than 50%<\/strong>.<\/p>\n<hr \/>\n<p>There is actually an awful lot more to this problem. A fascinating <a href=\"http:\/\/www.thebigquestions.com\/2011\/01\/07\/the-extra-half-boy\/\">follow up<\/a> guest post at Steve Landsburg\u00e2\u20ac\u2122s is worth reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There\u00e2\u20ac\u2122s a country where everybody wants to have a son. Therefore each couple keeps having children until they have a boy; then they stop. What fraction of the population is female? (You may assume the question is asked as an expectation of course, since any particular country can be anything in principle \u00e2\u20ac\u201d 100% girls\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.fussylogic.co.uk\/blog\/?p=489\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1,53],"tags":[35,33],"_links":{"self":[{"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/489"}],"collection":[{"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=489"}],"version-history":[{"count":5,"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/489\/revisions"}],"predecessor-version":[{"id":945,"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/489\/revisions\/945"}],"wp:attachment":[{"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}