{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "<div style=\"text-align: right\">Peter Norvig, 3 Oct 2015, revised Oct-Feb 2016</div> \n",
    "\n",
    "# Probability, Paradox, and the Reasonable Person Principle\n",
    "\n",
    "In [another notebook](http://nbviewer.jupyter.org/url/norvig.com/ipython/Probability.ipynb), I introduced the basics of probability theory. I'll duplicate the code we developed there:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "button": false,
    "collapsed": true,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [],
   "source": [
    "from fractions import Fraction\n",
    "\n",
    "class ProbDist(dict):\n",
    "    \"A Probability Distribution; an {outcome: probability} mapping.\"\n",
    "    def __init__(self, mapping=(), **kwargs):\n",
    "        self.update(mapping, **kwargs)\n",
    "        # Make probabilities sum to 1.0; assert no negative probabilities\n",
    "        total = sum(self.values())\n",
    "        for outcome in self:\n",
    "            self[outcome] = self[outcome] / total\n",
    "            assert self[outcome] >= 0\n",
    "            \n",
    "def P(event, space): \n",
    "    \"\"\"The probability of an event, given a sample space of equiprobable outcomes. \n",
    "    event: a collection of outcomes, or a predicate that is true of outcomes in the event. \n",
    "    space: a set of outcomes or a probability distribution of {outcome: frequency}.\"\"\"\n",
    "    if is_predicate(event):\n",
    "        event = such_that(event, space)\n",
    "    if isinstance(space, ProbDist):\n",
    "        return sum(space[o] for o in space if o in event)\n",
    "    else:\n",
    "        return Fraction(len(event & space), len(space))\n",
    "    \n",
    "def such_that(predicate, space): \n",
    "    \"\"\"The outcomes in the sample space for which the predicate is true.\n",
    "    If space is a set, return a subset {outcome,...};\n",
    "    if space is a ProbDist, return a ProbDist {outcome: frequency,...};\n",
    "    in both cases only with outcomes where predicate(element) is true.\"\"\"\n",
    "    if isinstance(space, ProbDist):\n",
    "        return ProbDist({o:space[o] for o in space if predicate(o)})\n",
    "    else:\n",
    "        return {o for o in space if predicate(o)}\n",
    "    \n",
    "is_predicate = callable\n",
    "\n",
    "def cross(A, B):\n",
    "    \"The set of ways of concatenating one item from collection A with one from B.\"\n",
    "    return {a + b \n",
    "            for a in A for b in B}\n",
    "\n",
    "def joint(A, B, sep=''):\n",
    "    \"\"\"The joint distribution of two independent probability distributions. \n",
    "    Result is all entries of the form {a+sep+b: P(a)*P(b)}\"\"\"\n",
    "    return ProbDist({a + sep + b: A[a] * B[b]\n",
    "                    for a in A\n",
    "                    for b in B})"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "In this notebook we use this code to show how to solve some particularly perplexing paradoxical probability problems.\n",
    "\n",
    "# Child Paradoxes\n",
    "\n",
    "In 1959, [Martin Gardner]() [posed](https://en.wikipedia.org/wiki/Boy_or_Girl_paradox) these two problems:\n",
    "\n",
    "- **Child Problem 1.** Mr. Jones has two children. The older child is a boy. What is the\n",
    "probability that both children are boys?\n",
    "\n",
    "- **Child Problem 2.** Mr. Smith has two children. At least one of them is a boy. What is\n",
    "the probability that both children are boys? \n",
    "\n",
    "Then in 2006, Mike & Tom Starbird came up with a variant, which Gary Foshee introduced to Gardner fans in 2010:\n",
    "\n",
    "- **Child Problem 3.** I have two children. At least one of them is a boy born on Tuesday. What is\n",
    "the probability that both children are boys? \n",
    "\n",
    "Problems 2 and 3 are considered *paradoxes* because they have surprising answers that people\n",
    "argue about. \n",
    "\n",
    "(Assume the probability of a boy is exactly 1/2, and is independent of any siblings.)\n",
    "\n",
    "![Martin Gardner](https://upload.wikimedia.org/wikipedia/commons/0/04/Martin_Gardner.jpeg)\n",
    "<center>Martin Gardner</center>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "### Child Problem 1: Older child is a boy. What is the probability both are boys?\n",
    "\n",
    "We use `'BG'` to denote the outcome in which the older child is a boy and the younger a girl. The sample space, `S`, of equi-probable outcomes is:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "button": false,
    "collapsed": true,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [],
   "source": [
    "S = {'BG', 'BB', 'GB', 'GG'}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "Let's define predicates for the conditions of having two boys, and of the older child being a boy:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [],
   "source": [
    "def two_boys(outcome): return outcome.count('B') == 2\n",
    "\n",
    "def older_is_a_boy(outcome): return outcome.startswith('B')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "Now we can answer Problem 1:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Fraction(1, 2)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "P(two_boys, such_that(older_is_a_boy, S))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "You're probably thinking that was a lot of mechanism just to get the obvious answer. But in the next problems, what is obvious becomes less obvious.\n",
    "\n",
    "### Child Problem 2: At least one is a boy. What is the probability both are boys? \n",
    "\n",
    "Implementing this problem and finding the answer is easy:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [],
   "source": [
    "def at_least_one_boy(outcome): return 'B' in outcome"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Fraction(1, 3)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "P(two_boys, such_that(at_least_one_boy, S))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "Understanding the answer is tougher. Some people think the answer should be 1/2. Can we justify the answer 1/3?  We can see there are three equiprobable outcomes in which there is at least one boy:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'BB', 'BG', 'GB'}"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "such_that(at_least_one_boy, S)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "Of those three outcomes, only one has two boys, so the answer of 1/3 is indeed justified. \n",
    "\n",
    "But some people *still* think the answer should be 1/2.\n",
    "Their reasoning is *\"If one child is a boy, then there are two equiprobable outcomes for the other child, so the probability that the other child is a boy, and thus that there are two boys, is 1/2.\"* \n",
    "\n",
    "When two methods of reasoning give two different answers, we have a [paradox](https://en.wikipedia.org/wiki/Paradox). Here are three responses to a paradox:\n",
    "\n",
    "1. The very fundamentals of mathematics must be incomplete, and this problem reveals it!!!\n",
    "2. I'm right, and anyone who disagrees with me is an idiot!!!\n",
    "3. I have the right answer for one interpretation of the problem, and you have the right answer\n",
    "for a different interpretation of the problem.\n",
    "\n",
    "If you're [Bertrand Russell](https://en.wikipedia.org/wiki/Russell%27s_paradox) or [Georg Cantor](https://en.wikipedia.org/wiki/Cantor%27s_paradox), you might very well uncover a fundamental flaw in mathematics; for the rest of us, I recommend Response 3. When I believe the answer is 1/3, and I hear someone say the answer is 1/2, my response is not *\"You're wrong!\"*, rather it is *\"How interesting! You must have a different interpretation of the problem; I should try to discover what your interpretation is, and why your answer is correct for your interpretation.\"* The first step is to be more precise in *my* wording of the experiment:\n",
    "\n",
    "- **Child Experiment 2a.** Mr. Smith is chosen at random from families with two children. He is asked if at least one of his children is a boy. He replies \"yes.\"\n",
    "\n",
    "The next step is to envision another possible interpretation of the experiment:\n",
    "\n",
    "- **Child Experiment 2b.** Mr. Smith is chosen at random from families with two children. He is observed at a time when he is accompanied by one of his children, chosen at random. The child is observed to be a boy.  \n",
    "\n",
    "Experiment 2b needs a different sample space, which we will call `S2b`.  It consists of 8 outcomes, not just 4; for each of the 4 outcomes in `S`, we have a choice of observing either the older child or the younger child.  We will use the notation `'GB/g?'` to mean that the older child is a girl, the younger a boy, the older child was observed to be a girl, and the younger was not observed. The sample space is therefore:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [],
   "source": [
    "S2b = {'BB/b?', 'BB/?b', \n",
    "       'BG/b?', 'BG/?g', \n",
    "       'GB/g?', 'GB/?b', \n",
    "       'GG/g?', 'GG/?g'}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "Now we can figure out the subset of this sample space in which we observe Mr. Smith with a boy:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'BB/?b', 'BB/b?', 'BG/b?', 'GB/?b'}"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def observed_boy(outcome): return 'b' in outcome\n",
    "\n",
    "such_that(observed_boy, S2b)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "And finally we can determine the probability that he has two boys, given that we observed him with a boy:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Fraction(1, 2)"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "P(two_boys, such_that(observed_boy, S2b))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "The paradox is resolved. Two reasonable people can have different interpretations of the problem, and can each reason flawlessly to reach different conclusions, 1/3 or 1/2. \n",
    "\n",
    "Which interpretation of the problem is \"better?\"  We could debate that, or we could just agree to use unambiguous wording (that is, use the language of Experiment 2a or Experiment 2b, not the ambiguous language of Problem 2). \n",
    "\n",
    "## The Reasonable Person Principle\n",
    "\n",
    "It is an unfortunate fact of human nature that we often assume the other person is an idiot. As [George Carlin puts it](https://www.youtube.com/watch?v=XWPCE2tTLZQ) *\"Have you ever noticed when you're driving that anybody driving slower than you is an idiot, and anyone going faster than you is a maniac?\"*\n",
    "\n",
    "<img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/2/2e/Jesus_is_coming.._Look_Busy_%28George_Carlin%29.jpg/192px-Jesus_is_coming.._Look_Busy_%28George_Carlin%29.jpg\">\n",
    "<center>George Carlin</center>\n",
    "\n",
    "The opposite assumption&mdash;that other people are more likely to be **reasonable** rather than **idiots** is known as the **[reasonable person principle](http://www.cs.cmu.edu/~weigand/staff/)**. It is a guiding principle at Carnegie Mellon University's School of Computer Science, and is a principle I try to live by as well.\n",
    "\n",
    "Now let's return to an even more paradoxical problem.\n",
    "\n",
    "### Child Problem 3. One is a boy born on Tuesday. What's the probability  both are boys?\n",
    "\n",
    "Most people can not imagine how the boy's birth-day-of-week could be relevant, and feel the answer should be the same as Problem 2.  But to be sure, we need to clearly describe the experiment, define the sample space, and calculate.  First:\n",
    "\n",
    "- **Child Experiment 3a.** A parent is chosen at random from families with two children. She is asked if at least one of her children is a boy born on Tuesday. She replies \"yes.\"\n",
    "\n",
    "Next we'll define a sample space. We'll use the notation \"`G1B3`\" to mean the older child is a girl born on the first day of the week (Sunday) and the younger a boy born on the third day of the week (Tuesday). We'll call the resulting sample space `S3`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "196"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sexesdays = cross('BG', '1234567')\n",
    "S3 = cross(sexesdays, sexesdays)\n",
    "len(S3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "run_control": {}
   },
   "source": [
    "That's too many to print, but we can sample them:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['G2G3', 'G6B7', 'B1G7', 'B4B7', 'B4G6', 'G5G5', 'B5G4', 'G4B4']"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import random\n",
    "random.sample(S3, 8)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "We determine below that the probability of having at least one boy is 3/4, both in `S3` (where we keep track of the birth day of week) and in `S` (where we don't):"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Fraction(3, 4)"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "P(at_least_one_boy, S3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Fraction(3, 4)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "P(at_least_one_boy, S)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "The probability of two boys is 1/4 in either sample space:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Fraction(1, 4)"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "P(two_boys, S3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Fraction(1, 4)"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "P(two_boys, S)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "And the probability of two boys given at least one boy is 1/3 in either sample space:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Fraction(1, 3)"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "P(two_boys, such_that(at_least_one_boy, S3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Fraction(1, 3)"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "P(two_boys, such_that(at_least_one_boy, S))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "We will define a predicate for the event of at least one boy born on Tuesday: "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [],
   "source": [
    "def at_least_one_boy_tues(outcome): return 'B3' in outcome"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "We are now ready to answer Problem 3:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Fraction(13, 27)"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "P(two_boys, such_that(at_least_one_boy_tues, S3))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "13/27? \n",
    "\n",
    "How many saw that coming? 13/27 is quite different from 1/3, but rather close to 1/2. So \"at least one boy born on Tuesday\" is quite different from \"at least one boy.\" Are you surprised? Do you accept the answer, or do you think we did something wrong? Are there other interpretations of the experiment that lead to other answers?\n",
    "\n",
    "Here is one alternative interpretation:"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "- **Child Experiment 3b.** A parent is chosen at random from families with two children. She is observed at a time when she is accompanied by one of her children, chosen at random. The child is observed to be a boy who reports that his birth day is Tuesday.\n",
    "\n",
    "We can represent outcomes in this sample space with the notation `G1B3/??b3`, meaning the older child is a girl born on Sunday, the younger a boy born on Tuesday, the older was not observed, and the younger was."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [],
   "source": [
    "def observed_boy_tues(outcome): return 'b3' in outcome\n",
    "\n",
    "S3b = {children + '/' + observation\n",
    "       for children in S3\n",
    "       for observation in (children[:2].lower()+'??', '??'+children[-2:].lower())}                        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['G4G5/??g5', 'B1B5/b1??', 'G6G4/g6??', 'B1G2/??g2', 'G5G6/g5??']"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.sample(S3b, 5)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "Now we can answer this version of  Child Problem 3:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Fraction(1, 2)"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "P(two_boys, such_that(observed_boy_tues, S3b))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "So with the wording of Child Experiment 3b, the answer is the same as 2b.\n",
    "\n",
    "Still confused? Let's build a visualization tool to make things more concrete.\n",
    "\n",
    "# Visualization\n",
    "\n",
    "We'll display the results as a two dimensional grid of outcomes. An outcome will be colored white if it does not satisfy the condition stated in the problem; green if the outcome contains two boys; and yellow if it does satisfy the condition, but does not have two boys. Every cell in a row has the same older child, and every cell in a column has the same younger child. Here's the code to display a table:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [],
   "source": [
    "from IPython.display import HTML\n",
    "\n",
    "def Pgrid(space, n, event, condition):\n",
    "    \"\"\"Display sample space in a grid, color-coded: green if event and condition is true; \n",
    "    yellow if only condition is true; white otherwise.\"\"\"\n",
    "    # n is the number of characters that make up the older child.\n",
    "    olders = sorted(set(outcome[:n] for outcome in space))\n",
    "    return HTML('<table>' +\n",
    "                cat(row(older, space, event, condition) for older in olders) +\n",
    "                '</table>' + \n",
    "                '<tt>P({} | {}) = {}</tt>'.format(\n",
    "                event.__name__, condition.__name__, \n",
    "                P(event, such_that(condition, space))))\n",
    "\n",
    "def row(older, space, event, condition):\n",
    "    \"Display a row where an older child is paired with each of the possible younger children.\"\n",
    "    thisrow = sorted(outcome for outcome in space if outcome.startswith(older))\n",
    "    return '<tr>' + cat(cell(outcome, event, condition) for outcome in thisrow) + '</tr>'\n",
    "\n",
    "def cell(outcome, event, condition): \n",
    "    \"Display outcome in appropriate color.\"\n",
    "    color = ('lightgreen' if event(outcome) and condition(outcome) else\n",
    "             'yellow' if condition(outcome) else\n",
    "             'white')\n",
    "    return '<td style=\"background-color: {}\">{}</td>'.format(color, outcome)    \n",
    "\n",
    "cat = ''.join"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "We can use this visualization tool to see that in Child Problem 1, there is one outcome with two boys (green) out of a total of two outcomes where the older is a boy (green and yellow) so the probability of two boys given that the older is a boy is 1/2."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table><tr><td style=\"background-color: lightgreen\">BB</td><td style=\"background-color: yellow\">BG</td></tr><tr><td style=\"background-color: white\">GB</td><td style=\"background-color: white\">GG</td></tr></table><tt>P(two_boys | older_is_a_boy) = 1/2</tt>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Child Problem 1\n",
    "Pgrid(S, 1, two_boys, older_is_a_boy)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "For Child Problem 2, we see the probability of two boys (green) given at least one boy (green and yellow)  is 1/3. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table><tr><td style=\"background-color: lightgreen\">BB</td><td style=\"background-color: yellow\">BG</td></tr><tr><td style=\"background-color: yellow\">GB</td><td style=\"background-color: white\">GG</td></tr></table><tt>P(two_boys | at_least_one_boy) = 1/3</tt>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Child Problem 2\n",
    "Pgrid(S, 1, two_boys, at_least_one_boy)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "The answer is still 1/3 when we consider the day of the week of each birth. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table><tr><td style=\"background-color: lightgreen\">B1B1</td><td style=\"background-color: lightgreen\">B1B2</td><td style=\"background-color: lightgreen\">B1B3</td><td style=\"background-color: lightgreen\">B1B4</td><td style=\"background-color: lightgreen\">B1B5</td><td style=\"background-color: lightgreen\">B1B6</td><td style=\"background-color: lightgreen\">B1B7</td><td style=\"background-color: yellow\">B1G1</td><td style=\"background-color: yellow\">B1G2</td><td style=\"background-color: yellow\">B1G3</td><td style=\"background-color: yellow\">B1G4</td><td style=\"background-color: yellow\">B1G5</td><td style=\"background-color: yellow\">B1G6</td><td style=\"background-color: yellow\">B1G7</td></tr><tr><td style=\"background-color: lightgreen\">B2B1</td><td style=\"background-color: lightgreen\">B2B2</td><td style=\"background-color: lightgreen\">B2B3</td><td style=\"background-color: lightgreen\">B2B4</td><td style=\"background-color: lightgreen\">B2B5</td><td style=\"background-color: lightgreen\">B2B6</td><td style=\"background-color: lightgreen\">B2B7</td><td style=\"background-color: yellow\">B2G1</td><td style=\"background-color: yellow\">B2G2</td><td style=\"background-color: yellow\">B2G3</td><td style=\"background-color: yellow\">B2G4</td><td style=\"background-color: yellow\">B2G5</td><td style=\"background-color: yellow\">B2G6</td><td style=\"background-color: yellow\">B2G7</td></tr><tr><td style=\"background-color: lightgreen\">B3B1</td><td style=\"background-color: lightgreen\">B3B2</td><td style=\"background-color: lightgreen\">B3B3</td><td style=\"background-color: lightgreen\">B3B4</td><td style=\"background-color: lightgreen\">B3B5</td><td style=\"background-color: lightgreen\">B3B6</td><td style=\"background-color: lightgreen\">B3B7</td><td style=\"background-color: yellow\">B3G1</td><td style=\"background-color: yellow\">B3G2</td><td style=\"background-color: yellow\">B3G3</td><td style=\"background-color: yellow\">B3G4</td><td style=\"background-color: yellow\">B3G5</td><td style=\"background-color: yellow\">B3G6</td><td style=\"background-color: yellow\">B3G7</td></tr><tr><td style=\"background-color: lightgreen\">B4B1</td><td style=\"background-color: lightgreen\">B4B2</td><td style=\"background-color: lightgreen\">B4B3</td><td style=\"background-color: lightgreen\">B4B4</td><td style=\"background-color: lightgreen\">B4B5</td><td style=\"background-color: lightgreen\">B4B6</td><td style=\"background-color: lightgreen\">B4B7</td><td style=\"background-color: yellow\">B4G1</td><td style=\"background-color: yellow\">B4G2</td><td style=\"background-color: yellow\">B4G3</td><td style=\"background-color: yellow\">B4G4</td><td style=\"background-color: yellow\">B4G5</td><td style=\"background-color: yellow\">B4G6</td><td style=\"background-color: yellow\">B4G7</td></tr><tr><td style=\"background-color: lightgreen\">B5B1</td><td style=\"background-color: lightgreen\">B5B2</td><td style=\"background-color: lightgreen\">B5B3</td><td style=\"background-color: lightgreen\">B5B4</td><td style=\"background-color: lightgreen\">B5B5</td><td style=\"background-color: lightgreen\">B5B6</td><td style=\"background-color: lightgreen\">B5B7</td><td style=\"background-color: yellow\">B5G1</td><td style=\"background-color: yellow\">B5G2</td><td style=\"background-color: yellow\">B5G3</td><td style=\"background-color: yellow\">B5G4</td><td style=\"background-color: yellow\">B5G5</td><td style=\"background-color: yellow\">B5G6</td><td style=\"background-color: yellow\">B5G7</td></tr><tr><td style=\"background-color: lightgreen\">B6B1</td><td style=\"background-color: lightgreen\">B6B2</td><td style=\"background-color: lightgreen\">B6B3</td><td style=\"background-color: lightgreen\">B6B4</td><td style=\"background-color: lightgreen\">B6B5</td><td style=\"background-color: lightgreen\">B6B6</td><td style=\"background-color: lightgreen\">B6B7</td><td style=\"background-color: yellow\">B6G1</td><td style=\"background-color: yellow\">B6G2</td><td style=\"background-color: yellow\">B6G3</td><td style=\"background-color: yellow\">B6G4</td><td style=\"background-color: yellow\">B6G5</td><td style=\"background-color: yellow\">B6G6</td><td style=\"background-color: yellow\">B6G7</td></tr><tr><td style=\"background-color: lightgreen\">B7B1</td><td style=\"background-color: lightgreen\">B7B2</td><td style=\"background-color: lightgreen\">B7B3</td><td style=\"background-color: lightgreen\">B7B4</td><td style=\"background-color: lightgreen\">B7B5</td><td style=\"background-color: lightgreen\">B7B6</td><td style=\"background-color: lightgreen\">B7B7</td><td style=\"background-color: yellow\">B7G1</td><td style=\"background-color: yellow\">B7G2</td><td style=\"background-color: yellow\">B7G3</td><td style=\"background-color: yellow\">B7G4</td><td style=\"background-color: yellow\">B7G5</td><td style=\"background-color: yellow\">B7G6</td><td style=\"background-color: yellow\">B7G7</td></tr><tr><td style=\"background-color: yellow\">G1B1</td><td style=\"background-color: yellow\">G1B2</td><td style=\"background-color: yellow\">G1B3</td><td style=\"background-color: yellow\">G1B4</td><td style=\"background-color: yellow\">G1B5</td><td style=\"background-color: yellow\">G1B6</td><td style=\"background-color: yellow\">G1B7</td><td style=\"background-color: white\">G1G1</td><td style=\"background-color: white\">G1G2</td><td style=\"background-color: white\">G1G3</td><td style=\"background-color: white\">G1G4</td><td style=\"background-color: white\">G1G5</td><td style=\"background-color: white\">G1G6</td><td style=\"background-color: white\">G1G7</td></tr><tr><td style=\"background-color: yellow\">G2B1</td><td style=\"background-color: yellow\">G2B2</td><td style=\"background-color: yellow\">G2B3</td><td style=\"background-color: yellow\">G2B4</td><td style=\"background-color: yellow\">G2B5</td><td style=\"background-color: yellow\">G2B6</td><td style=\"background-color: yellow\">G2B7</td><td style=\"background-color: white\">G2G1</td><td style=\"background-color: white\">G2G2</td><td style=\"background-color: white\">G2G3</td><td style=\"background-color: white\">G2G4</td><td style=\"background-color: white\">G2G5</td><td style=\"background-color: white\">G2G6</td><td style=\"background-color: white\">G2G7</td></tr><tr><td style=\"background-color: yellow\">G3B1</td><td style=\"background-color: yellow\">G3B2</td><td style=\"background-color: yellow\">G3B3</td><td style=\"background-color: yellow\">G3B4</td><td style=\"background-color: yellow\">G3B5</td><td style=\"background-color: yellow\">G3B6</td><td style=\"background-color: yellow\">G3B7</td><td style=\"background-color: white\">G3G1</td><td style=\"background-color: white\">G3G2</td><td style=\"background-color: white\">G3G3</td><td style=\"background-color: white\">G3G4</td><td style=\"background-color: white\">G3G5</td><td style=\"background-color: white\">G3G6</td><td style=\"background-color: white\">G3G7</td></tr><tr><td style=\"background-color: yellow\">G4B1</td><td style=\"background-color: yellow\">G4B2</td><td style=\"background-color: yellow\">G4B3</td><td style=\"background-color: yellow\">G4B4</td><td style=\"background-color: yellow\">G4B5</td><td style=\"background-color: yellow\">G4B6</td><td style=\"background-color: yellow\">G4B7</td><td style=\"background-color: white\">G4G1</td><td style=\"background-color: white\">G4G2</td><td style=\"background-color: white\">G4G3</td><td style=\"background-color: white\">G4G4</td><td style=\"background-color: white\">G4G5</td><td style=\"background-color: white\">G4G6</td><td style=\"background-color: white\">G4G7</td></tr><tr><td style=\"background-color: yellow\">G5B1</td><td style=\"background-color: yellow\">G5B2</td><td style=\"background-color: yellow\">G5B3</td><td style=\"background-color: yellow\">G5B4</td><td style=\"background-color: yellow\">G5B5</td><td style=\"background-color: yellow\">G5B6</td><td style=\"background-color: yellow\">G5B7</td><td style=\"background-color: white\">G5G1</td><td style=\"background-color: white\">G5G2</td><td style=\"background-color: white\">G5G3</td><td style=\"background-color: white\">G5G4</td><td style=\"background-color: white\">G5G5</td><td style=\"background-color: white\">G5G6</td><td style=\"background-color: white\">G5G7</td></tr><tr><td style=\"background-color: yellow\">G6B1</td><td style=\"background-color: yellow\">G6B2</td><td style=\"background-color: yellow\">G6B3</td><td style=\"background-color: yellow\">G6B4</td><td style=\"background-color: yellow\">G6B5</td><td style=\"background-color: yellow\">G6B6</td><td style=\"background-color: yellow\">G6B7</td><td style=\"background-color: white\">G6G1</td><td style=\"background-color: white\">G6G2</td><td style=\"background-color: white\">G6G3</td><td style=\"background-color: white\">G6G4</td><td style=\"background-color: white\">G6G5</td><td style=\"background-color: white\">G6G6</td><td style=\"background-color: white\">G6G7</td></tr><tr><td style=\"background-color: yellow\">G7B1</td><td style=\"background-color: yellow\">G7B2</td><td style=\"background-color: yellow\">G7B3</td><td style=\"background-color: yellow\">G7B4</td><td style=\"background-color: yellow\">G7B5</td><td style=\"background-color: yellow\">G7B6</td><td style=\"background-color: yellow\">G7B7</td><td style=\"background-color: white\">G7G1</td><td style=\"background-color: white\">G7G2</td><td style=\"background-color: white\">G7G3</td><td style=\"background-color: white\">G7G4</td><td style=\"background-color: white\">G7G5</td><td style=\"background-color: white\">G7G6</td><td style=\"background-color: white\">G7G7</td></tr></table><tt>P(two_boys | at_least_one_boy) = 1/3</tt>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Child Problem 2, with days of week enumerated\n",
    "Pgrid(S3, 2, two_boys, at_least_one_boy)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "\n",
    "\n",
    "Now for the paradox of Child Problem 3:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table><tr><td style=\"background-color: white\">B1B1</td><td style=\"background-color: white\">B1B2</td><td style=\"background-color: lightgreen\">B1B3</td><td style=\"background-color: white\">B1B4</td><td style=\"background-color: white\">B1B5</td><td style=\"background-color: white\">B1B6</td><td style=\"background-color: white\">B1B7</td><td style=\"background-color: white\">B1G1</td><td style=\"background-color: white\">B1G2</td><td style=\"background-color: white\">B1G3</td><td style=\"background-color: white\">B1G4</td><td style=\"background-color: white\">B1G5</td><td style=\"background-color: white\">B1G6</td><td style=\"background-color: white\">B1G7</td></tr><tr><td style=\"background-color: white\">B2B1</td><td style=\"background-color: white\">B2B2</td><td style=\"background-color: lightgreen\">B2B3</td><td style=\"background-color: white\">B2B4</td><td style=\"background-color: white\">B2B5</td><td style=\"background-color: white\">B2B6</td><td style=\"background-color: white\">B2B7</td><td style=\"background-color: white\">B2G1</td><td style=\"background-color: white\">B2G2</td><td style=\"background-color: white\">B2G3</td><td style=\"background-color: white\">B2G4</td><td style=\"background-color: white\">B2G5</td><td style=\"background-color: white\">B2G6</td><td style=\"background-color: white\">B2G7</td></tr><tr><td style=\"background-color: lightgreen\">B3B1</td><td style=\"background-color: lightgreen\">B3B2</td><td style=\"background-color: lightgreen\">B3B3</td><td style=\"background-color: lightgreen\">B3B4</td><td style=\"background-color: lightgreen\">B3B5</td><td style=\"background-color: lightgreen\">B3B6</td><td style=\"background-color: lightgreen\">B3B7</td><td style=\"background-color: yellow\">B3G1</td><td style=\"background-color: yellow\">B3G2</td><td style=\"background-color: yellow\">B3G3</td><td style=\"background-color: yellow\">B3G4</td><td style=\"background-color: yellow\">B3G5</td><td style=\"background-color: yellow\">B3G6</td><td style=\"background-color: yellow\">B3G7</td></tr><tr><td style=\"background-color: white\">B4B1</td><td style=\"background-color: white\">B4B2</td><td style=\"background-color: lightgreen\">B4B3</td><td style=\"background-color: white\">B4B4</td><td style=\"background-color: white\">B4B5</td><td style=\"background-color: white\">B4B6</td><td style=\"background-color: white\">B4B7</td><td style=\"background-color: white\">B4G1</td><td style=\"background-color: white\">B4G2</td><td style=\"background-color: white\">B4G3</td><td style=\"background-color: white\">B4G4</td><td style=\"background-color: white\">B4G5</td><td style=\"background-color: white\">B4G6</td><td style=\"background-color: white\">B4G7</td></tr><tr><td style=\"background-color: white\">B5B1</td><td style=\"background-color: white\">B5B2</td><td style=\"background-color: lightgreen\">B5B3</td><td style=\"background-color: white\">B5B4</td><td style=\"background-color: white\">B5B5</td><td style=\"background-color: white\">B5B6</td><td style=\"background-color: white\">B5B7</td><td style=\"background-color: white\">B5G1</td><td style=\"background-color: white\">B5G2</td><td style=\"background-color: white\">B5G3</td><td style=\"background-color: white\">B5G4</td><td style=\"background-color: white\">B5G5</td><td style=\"background-color: white\">B5G6</td><td style=\"background-color: white\">B5G7</td></tr><tr><td style=\"background-color: white\">B6B1</td><td style=\"background-color: white\">B6B2</td><td style=\"background-color: lightgreen\">B6B3</td><td style=\"background-color: white\">B6B4</td><td style=\"background-color: white\">B6B5</td><td style=\"background-color: white\">B6B6</td><td style=\"background-color: white\">B6B7</td><td style=\"background-color: white\">B6G1</td><td style=\"background-color: white\">B6G2</td><td style=\"background-color: white\">B6G3</td><td style=\"background-color: white\">B6G4</td><td style=\"background-color: white\">B6G5</td><td style=\"background-color: white\">B6G6</td><td style=\"background-color: white\">B6G7</td></tr><tr><td style=\"background-color: white\">B7B1</td><td style=\"background-color: white\">B7B2</td><td style=\"background-color: lightgreen\">B7B3</td><td style=\"background-color: white\">B7B4</td><td style=\"background-color: white\">B7B5</td><td style=\"background-color: white\">B7B6</td><td style=\"background-color: white\">B7B7</td><td style=\"background-color: white\">B7G1</td><td style=\"background-color: white\">B7G2</td><td style=\"background-color: white\">B7G3</td><td style=\"background-color: white\">B7G4</td><td style=\"background-color: white\">B7G5</td><td style=\"background-color: white\">B7G6</td><td style=\"background-color: white\">B7G7</td></tr><tr><td style=\"background-color: white\">G1B1</td><td style=\"background-color: white\">G1B2</td><td style=\"background-color: yellow\">G1B3</td><td style=\"background-color: white\">G1B4</td><td style=\"background-color: white\">G1B5</td><td style=\"background-color: white\">G1B6</td><td style=\"background-color: white\">G1B7</td><td style=\"background-color: white\">G1G1</td><td style=\"background-color: white\">G1G2</td><td style=\"background-color: white\">G1G3</td><td style=\"background-color: white\">G1G4</td><td style=\"background-color: white\">G1G5</td><td style=\"background-color: white\">G1G6</td><td style=\"background-color: white\">G1G7</td></tr><tr><td style=\"background-color: white\">G2B1</td><td style=\"background-color: white\">G2B2</td><td style=\"background-color: yellow\">G2B3</td><td style=\"background-color: white\">G2B4</td><td style=\"background-color: white\">G2B5</td><td style=\"background-color: white\">G2B6</td><td style=\"background-color: white\">G2B7</td><td style=\"background-color: white\">G2G1</td><td style=\"background-color: white\">G2G2</td><td style=\"background-color: white\">G2G3</td><td style=\"background-color: white\">G2G4</td><td style=\"background-color: white\">G2G5</td><td style=\"background-color: white\">G2G6</td><td style=\"background-color: white\">G2G7</td></tr><tr><td style=\"background-color: white\">G3B1</td><td style=\"background-color: white\">G3B2</td><td style=\"background-color: yellow\">G3B3</td><td style=\"background-color: white\">G3B4</td><td style=\"background-color: white\">G3B5</td><td style=\"background-color: white\">G3B6</td><td style=\"background-color: white\">G3B7</td><td style=\"background-color: white\">G3G1</td><td style=\"background-color: white\">G3G2</td><td style=\"background-color: white\">G3G3</td><td style=\"background-color: white\">G3G4</td><td style=\"background-color: white\">G3G5</td><td style=\"background-color: white\">G3G6</td><td style=\"background-color: white\">G3G7</td></tr><tr><td style=\"background-color: white\">G4B1</td><td style=\"background-color: white\">G4B2</td><td style=\"background-color: yellow\">G4B3</td><td style=\"background-color: white\">G4B4</td><td style=\"background-color: white\">G4B5</td><td style=\"background-color: white\">G4B6</td><td style=\"background-color: white\">G4B7</td><td style=\"background-color: white\">G4G1</td><td style=\"background-color: white\">G4G2</td><td style=\"background-color: white\">G4G3</td><td style=\"background-color: white\">G4G4</td><td style=\"background-color: white\">G4G5</td><td style=\"background-color: white\">G4G6</td><td style=\"background-color: white\">G4G7</td></tr><tr><td style=\"background-color: white\">G5B1</td><td style=\"background-color: white\">G5B2</td><td style=\"background-color: yellow\">G5B3</td><td style=\"background-color: white\">G5B4</td><td style=\"background-color: white\">G5B5</td><td style=\"background-color: white\">G5B6</td><td style=\"background-color: white\">G5B7</td><td style=\"background-color: white\">G5G1</td><td style=\"background-color: white\">G5G2</td><td style=\"background-color: white\">G5G3</td><td style=\"background-color: white\">G5G4</td><td style=\"background-color: white\">G5G5</td><td style=\"background-color: white\">G5G6</td><td style=\"background-color: white\">G5G7</td></tr><tr><td style=\"background-color: white\">G6B1</td><td style=\"background-color: white\">G6B2</td><td style=\"background-color: yellow\">G6B3</td><td style=\"background-color: white\">G6B4</td><td style=\"background-color: white\">G6B5</td><td style=\"background-color: white\">G6B6</td><td style=\"background-color: white\">G6B7</td><td style=\"background-color: white\">G6G1</td><td style=\"background-color: white\">G6G2</td><td style=\"background-color: white\">G6G3</td><td style=\"background-color: white\">G6G4</td><td style=\"background-color: white\">G6G5</td><td style=\"background-color: white\">G6G6</td><td style=\"background-color: white\">G6G7</td></tr><tr><td style=\"background-color: white\">G7B1</td><td style=\"background-color: white\">G7B2</td><td style=\"background-color: yellow\">G7B3</td><td style=\"background-color: white\">G7B4</td><td style=\"background-color: white\">G7B5</td><td style=\"background-color: white\">G7B6</td><td style=\"background-color: white\">G7B7</td><td style=\"background-color: white\">G7G1</td><td style=\"background-color: white\">G7G2</td><td style=\"background-color: white\">G7G3</td><td style=\"background-color: white\">G7G4</td><td style=\"background-color: white\">G7G5</td><td style=\"background-color: white\">G7G6</td><td style=\"background-color: white\">G7G7</td></tr></table><tt>P(two_boys | at_least_one_boy_tues) = 13/27</tt>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Child Problem 3\n",
    "Pgrid(S3, 2, two_boys, at_least_one_boy_tues)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "We see there are 27 relevant outcomes, of which 13 are green. So 13/27 really does seem to be the right answer. This picture also gives us a way to think about why the answer is not 1/3. Think of the yellow-plus-green area as a horizontal stripe and a vertical stripe, with an overlap. Each stripe is half yellow and half green, so if there were no overlap at all, the probability of green would be 1/2.  When each stripe takes up half the sample space and the overlap is maximal, the probability is 1/3. And in the Problem 3 table, where the overlap is small, the probability is close to 1/2 (but slightly smaller).\n",
    "\n",
    "One way to look at it is that if I tell you very specific information (such as a boy born on Tuesday), it is unlikely that this applies to both children, so we have smaller overlap and a probability closer to 1/2, but if I give you broad information (a boy), this is more likely to apply to either child, resulting in a larger overlap, and a probability closer to 1/3.\n",
    "\n",
    "You can read some more discussions of the problem by (in alphabetical order) \n",
    "[Alex Bellos](https://www.newscientist.com/article/dn18950-magic-numbers-a-meeting-of-mathemagical-tricksters?full=true),\n",
    "[Alexander Bogomolny](http://www.cut-the-knot.org/Probability/BearBornOnTuesday.shtml),\n",
    "[Andrew Gelman](http://andrewgelman.com/2010/05/27/hype_about_cond/),\n",
    "[David Bigelow](https://web.viu.ca/bigelow2/Problem%201127%20Solution.pdf),\n",
    "[Julie Rehmeyer](https://www.sciencenews.org/article/when-intuition-and-math-probably-look-wrong),\n",
    "[Keith Devlin](https://www.maa.org/external_archive/devlin/devlin_05_10.html),\n",
    "[Peter Lynch](http://mathsci.ucd.ie/~plynch/Publications/BIMS-TwoChildParadox.pdf),\n",
    "[Tanya Khovanova](http://arxiv.org/pdf/1102.0173v1.pdf),\n",
    "and\n",
    "[Wendy Taylor &amp; Kaye Stacey](http://www.aamt.edu.au/Journals/Sample-articles/amt70_2_taylor.pdf)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "# The Sleeping Beauty Paradox\n",
    "\n",
    "The [Sleeping Beauty Paradox](https://en.wikipedia.org/wiki/Sleeping_Beauty_problem) is another tricky one:\n",
    "\n",
    ">Sleeping Beauty volunteers to undergo the following experiment and is told all of the following details: On Sunday she will be put to sleep. Then a fair coin will be tossed,\n",
    "to determine which experimental procedure to undertake:\n",
    "- Heads: Beauty will be awakened and interviewed on Monday only.\n",
    "- Tails: Beauty will be awakened and interviewed on Monday and Tuesday only.\n",
    "\n",
    ">In all cases she is put back to sleep with an amnesia-inducing drug that makes her forget that awakening and sleep until the next one. In any case, she will be awakened on Wednesday without interview and the experiment ends. Any time Beauty is awakened and interviewed, she is asked, \"What is your belief now for the proposition that the coin landed heads?\"\n",
    "\n",
    "What should Sleeping Beauty say when she is interviewed?  First, she should define the sample space.  She could use the notation `'heads/Monday/interviewed'` to mean the outcome where the coin flip was heads, it is Monday, and she is interviewed. So there are 4 equiprobable outcomes:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "button": false,
    "collapsed": true,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [],
   "source": [
    "B = {'heads/Monday/interviewed', 'heads/Tuesday/sleep',\n",
    "     'tails/Monday/interviewed', 'tails/Tuesday/interviewed'}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "At this point, you're probably expecting me to define predicates, like this:\n",
    "\n",
    "    def heads(outcome): return 'heads' in outcome\n",
    "    def interviewed(outcome): return 'interviewed' in outcome\n",
    "    \n",
    "We've seen a lot of predicates like this. I think it is time to heed the \"[don't repeat yourself](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself)\" principle, so I will define a predicate-defining function, `T`. Think of \"`T`\" for \"it is true that\":"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "button": false,
    "collapsed": true,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [],
   "source": [
    "def T(property):\n",
    "    \"Return a predicate that is true of all outcomes that have 'property' as a substring.\"\n",
    "    return lambda outcome: property in outcome"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "Now we can get the answer:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Fraction(1, 3)"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "heads = T(\"heads\")\n",
    "interviewed = T(\"interviewed\")\n",
    "\n",
    "P(heads, such_that(interviewed, B))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "Note: I could have done that in one line: `P(T(\"heads\"), such_that(T(\"interviewed\"), B))`\n",
    "\n",
    "This problem is considered a paradox because there are people who argue that the answer should be 1/2, not 1/3. I admit I'm having difficulty coming up with a sample space that supports the \"halfer\" position. \n",
    "\n",
    "I do know of a question that has the answer 1/2:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Fraction(1, 2)"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "P(heads, B) "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "But that seems like the wrong question; we want the probability of heads given that Sleeping Beauty was interviewed, not the unconditional probability of heads.\n",
    "\n",
    "The \"halfers\" argue that before Sleeping Beauty goes to sleep, her unconditional probability for heads should be 1/2. When she is interviewed, she doesn't know anything more than before she went to sleep, so nothing has changed, so the probability of heads should still be 1/2. I find two flaws with this argument. First, if you want to convince me, show me a sample space; don't just make philosophical arguments. (Although a philosophical argument can be employed to help you define the right sample space.) Second, while I agree that before she goes to sleep, Beauty's *unconditional* probability for heads should be 1/2, I would say that both before she goes to sleep and when she is awakened, her *conditional* probability of heads *given that she is being interviewed* should be 1/3, as shown by the sample space."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "# The Monty Hall Paradox\n",
    "\n",
    "[This](https://en.wikipedia.org/wiki/Monty_Hall_problem) is one of the most famous probability paradoxes. It can be stated as follows:\n",
    "\n",
    "> Suppose you're on a game show, and you're given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1, and the host, who knows what's behind the doors, opens another door, say No. 3, which has a goat. He then says to you, \"Do you want to switch your choice to door No. 2?\" Is it to your advantage to switch your choice?\n",
    "\n",
    "<img src=\"http://retrothing.typepad.com/.a/6a00d83452989a69e20120a4cb10a2970b-800wi\">\n",
    "<center>Monty Hall</center>\n",
    "\n",
    "Much has been written about this problem, but to solve it all we have to do is be careful about how we understand the problem, and about defining our sample space.  I will define outcomes of the form `'Car1/Lo/Pick1/Open2'`, which means:\n",
    "* `Car1`: The producers of the show randomly placed the car behind door 1.\n",
    "* `Lo`: The host randomly commits to the strategy of opening the lowest-numbered allowable door. A door is allowable if it does not contain the car and was not picked by the contestant. Alternatively, the host could have chosen to open the highest-numbered allowable door (`Hi`).\n",
    "* `Pick1`: The contestant picks door 1.  Our sample space will only consider cases where the contestant picks door 1, but by symmetry, the same arguments could be used if the contestant picked door 2 or 3.\n",
    "* `Open2`: After hearing the contestant's choice, and following the strategy, the host opens a door; in this case door 2.\n",
    "\n",
    "We can see that the sample space has 6 equiprobable outcomes involving `Pick1`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "button": false,
    "collapsed": true,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [],
   "source": [
    "M = {'Car1/Lo/Pick1/Open2', 'Car1/Hi/Pick1/Open3',\n",
    "     'Car2/Lo/Pick1/Open3', 'Car2/Hi/Pick1/Open3',\n",
    "     'Car3/Lo/Pick1/Open2', 'Car3/Hi/Pick1/Open2'}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "Now, assuming the contestant picks door 1 and the host opens door 3, we can ask:\n",
    "- What are the possible outcomes remaining?\n",
    "- What is the probability that the car is behind door 1? \n",
    "- Or door 2?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Car1/Hi/Pick1/Open3', 'Car2/Hi/Pick1/Open3', 'Car2/Lo/Pick1/Open3'}"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "such_that(T(\"Open3\"), M)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Fraction(1, 3)"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "P(T(\"Car1\"), such_that(T(\"Open3\"), M))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Fraction(2, 3)"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "P(T(\"Car2\"), such_that(T(\"Open3\"), M))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "We see that the strategy of **switching** from door 1 to door 2 will win the car 2/3 of the time, whereas the strategy of **sticking** with the original pick wins the car only 1/3 of the time. So if you like cars more than goats, you should switch. But don't feel bad if you got this one wrong; it turns out that Monty Hall himself, who opened many doors while hosting *Let's Make a Deal* for 13 years, didn't know the answer either, as revealed in this letter from Monty to Prof. Lawrence Denenberg, when Denenberg asked for permission to use the problem in his textbook:\n",
    "<img src=\"http://norvig.com/monty-hall-letter.jpg\">\n",
    "\n",
    "If you were Denenberg, how would you answer Monty, in non-mathematical terms?  I would try something like this:\n",
    "\n",
    "> When the contestant makes her initial pick, she has 1/3 chance of picking the car, and there is a 2/3 chance the car is behind one of the other doors. That's still true after you open a door, but now the 2/3 chance for *either* other door becomes concentrated as 2/3 behind *one* other door, so the contestant should switch.\n",
    "\n",
    "But that type of argument was not persuasive to everyone. [Marilyn vos Savant](http://marilynvossavant.com/game-show-problem/) reports that many of her readers (including, she is pleased to point out, many Ph.D.s) still insist the answer is that it doesn't matter if the contestant switches; the odds are 1/2 either way. Let's try to discover what problem and what sample space those people are dealing with. Perhaps they are reasoning like this:\n",
    "\n",
    "They define outcomes of the form `'Car1/Pick1/Open2/Goat'`, which means:\n",
    "* `Car1`: First the car is randomly placed behind door 1.\n",
    "* `Pick1`: The contestant picks door 1.  \n",
    "* `Open2`: The host opens one of the two other doors at random (so the host might open the door with the car).\n",
    "* `Goat`: We observe there is a goat behind the opened door.\n",
    "\n",
    "Under this interpretation, the sample space of all outcomes involving `Pick1` is:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "button": false,
    "collapsed": true,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [],
   "source": [
    "M2 = {'Car1/Pick1/Open2/Goat', 'Car1/Pick1/Open3/Goat',\n",
    "      'Car2/Pick1/Open2/Car',  'Car2/Pick1/Open3/Goat',\n",
    "      'Car3/Pick1/Open2/Goat', 'Car3/Pick1/Open3/Car'}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "And we can calculate the probability of the car being behind each door, given that the contestant picks door 1 and the host opens door 3 to reveal a goat:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Fraction(1, 2)"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "P(T(\"Car1\"), such_that(T(\"Open3/Goat\"), M2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Fraction(1, 2)"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "P(T(\"Car2\"), such_that(T(\"Open3/Goat\"), M2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Fraction(0, 1)"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "P(T(\"Car3\"), such_that(T(\"Open3/Goat\"), M2))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "So we see that under this interpretation it doesn't matter if you switch or not. \n",
    "\n",
    "Is this a valid interpretation? I agree that the wording of the problem can be seen as being ambiguous. However, this interpretation has a serious problem: in all the history of *Let's Make a Deal*, it was never the case that the host opened up a door with the grand prize.  This strongly suggests (but does not prove) that `M`  is the correct sample space, not `M2`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "run_control": {}
   },
   "source": [
    "# Simulating the Monty Hall Problem\n",
    "\n",
    "Some people might be more convinced by a simulation than by a probability argument. Here is code for a simulation:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [],
   "source": [
    "import random\n",
    "\n",
    "\n",
    "def monty(strategy):\n",
    "    \"\"\"Simulate this sequence of events:\n",
    "    1. The host randomly chooses a door for the 'car'\n",
    "    2. The contestant randomly makes a 'pick' of one of the doors\n",
    "    3. The host randomly selects a non-car, non-pick door to be 'opened.' \n",
    "    4. If strategy == 'switch', contestant changes 'pick' to the other unopened door\n",
    "    5. Return true if the pick is the door with the car.\"\"\"\n",
    "    doors  = (1, 2, 3)\n",
    "    car    = random.choice(doors)\n",
    "    pick   = random.choice(doors)\n",
    "    opened = random.choice([d for d in doors if d != car and d != pick])\n",
    "    if strategy == 'switch':\n",
    "        pick = next(d for d in doors if d != pick and d != opened)\n",
    "    return (pick == car)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "We can confirm that the contestant wins about 2/3 of the time with the `switch` strategy, and only wins about 1/3 of the time with the `stick` strategy:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Counter({False: 33110, True: 66890})"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from collections import Counter\n",
    "\n",
    "Counter(monty('switch') for _ in range(10 ** 5))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Counter({False: 66738, True: 33262})"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Counter(monty('stick') for _ in range(10 ** 5))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "# Reasoning with Probability Distributions\n",
    "\n",
    "So far, we have made the assumption that every outcome in a sample space is equally likely. In real life, the probability of a child being a girl is not exactly 1/2. As mentioned in the [previous notebook](http://nbviewer.jupyter.org/url/norvig.com/ipython/Probability.ipynb), an [article](http://people.kzoo.edu/barth/math105/moreboys.pdf) gives the following counts for two-child families in Denmark:\n",
    "\n",
    "    GG: 121801    GB: 126840\n",
    "    BG: 127123    BB: 135138\n",
    "\n",
    "Let's implement that:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'BB': 0.2645086533229465,\n",
       " 'BG': 0.24882071317004043,\n",
       " 'GB': 0.24826679089140383,\n",
       " 'GG': 0.23840384261560926}"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "DK = ProbDist(GG=121801, GB=126840,\n",
    "              BG=127123, BB=135138)\n",
    "DK"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "Now let's try the first two Child Problems with the probability distribution `DK`. Since boys are slightly more probable than girls, we expect a little over 1/2 for Problem 1, and a little over 1/3 for problem 2:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.5152805792702689"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Child Problem 1 in DK\n",
    "P(two_boys, such_that(older_is_a_boy, DK))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.3473082824253857"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Child Problem 2 in DK\n",
    "P(two_boys, such_that(at_least_one_boy, DK))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "It all looks good. Now let's leave Denmark behind and try a new problem:\n",
    "\n",
    "### Child Problem 4. One is a boy born on Feb. 29. What is the probability both are boys?\n",
    "\n",
    "* **Child Problem 4.** I have two children. At least one of them is a boy born on leap day, February 29. What is the probability that both children are boys? Assume that 51.5% of births are boys and that birth days are distributed evenly across the 4&times;365 + 1 days in a 4-year cycle.\n",
    "\n",
    "We will use the notation `GLBN` to mean an older girl born on leap day (`L`) and a younger boy born on a non-leap day (`N`). "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [],
   "source": [
    "sexes = ProbDist(B=51.5, G=48.5)   # Probability distribution over sexes\n",
    "days  = ProbDist(L=1, N=4*365)     # Probability distribution over Leap days and Non-leap days\n",
    "child = joint(sexes, days)         # Probability distribution for one child family\n",
    "S4    = joint(child, child)        # Probability distribution for two-child family"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "Let's check out these last two probability distributions:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'BL': 0.00035249828884325804,\n",
       " 'BN': 0.5146475017111568,\n",
       " 'GL': 0.0003319644079397673,\n",
       " 'GN': 0.48466803559206023}"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "child"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'BLBL': 1.2425504363742495e-07,\n",
       " 'BLBN': 0.00018141236371064045,\n",
       " 'BLGL': 1.170168857556332e-07,\n",
       " 'BLGN': 0.0001708446532032245,\n",
       " 'BNBL': 0.00018141236371064045,\n",
       " 'BNBN': 0.26486205101753507,\n",
       " 'BNGL': 0.00017084465320322452,\n",
       " 'BNGN': 0.24943319367670777,\n",
       " 'GLBL': 1.170168857556332e-07,\n",
       " 'GLBN': 0.00017084465320322452,\n",
       " 'GLGL': 1.102003681388002e-07,\n",
       " 'GLGN': 0.0001608925374826483,\n",
       " 'GNBL': 0.0001708446532032245,\n",
       " 'GNBN': 0.24943319367670777,\n",
       " 'GNGL': 0.0001608925374826483,\n",
       " 'GNGN': 0.2349031047246665}"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "S4"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "Now we can solve the problem. Since \"boy born on a leap day\" applies to so few children, we expect the probability of two boys to be just ever so slightly below the baseline rate for boys, 51.5%."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.5149145040963757"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Child Problem 4\n",
    "boy_born_on_leap_day = T(\"BL\")\n",
    "\n",
    "P(two_boys, such_that(boy_born_on_leap_day, S4))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "# The St. Petersburg Paradox\n",
    "\n",
    "The [St. Petersburg paradox](https://en.wikipedia.org/wiki/St._Petersburg_paradox) from 1713, named for the home town of the [Bernoullis](http://www.storyofmathematics.com/18th_bernoulli.html), and introduced by [Daniel Bernoulli](), the nephew of Jacob Bernoulli (the urn guy):\n",
    "\n",
    "> *A casino offers a game of chance for a single player in which a fair coin is tossed at each stage. The pot starts at 2 dollars and is doubled every time a head appears. The first time a tail appears, the game ends and the player wins whatever is in the pot. Thus the player wins 2 dollars if a tail appears on the first toss, 4 dollars if a head appears on the first toss and a tail on the second, etc. What is the expected value of this game to the player?*\n",
    "\n",
    "To calculate the expected value, we see there is a 1/2 chance of a tail on the first toss (yielding a pot of $2) and if not that, a 1/2 &times; 1/2 = 1/4 chance of a tail on the second toss (yielding a pot of $4), and so on. So in total, the expected value is:\n",
    "\n",
    "      2 * (1/2) + 4 * (1/4) + 8 * (1/8) + ... = 1 + 1 + 1 + ... = ∞\n",
    "\n",
    "The expected value is infinite! But anyone playing the game would not expect to win an infinite amount; thus the paradox.\n",
    "\n",
    "## Response 1: Limited Resources\n",
    "\n",
    "The first major response to the paradox is that the casino's resources are limited. Once you break their bank, they can't pay out any more, and thus the expected return is finite. Let's consider the case where the bank has a limit to their resources, and create a probability distribution for the problem. We keep doubling the pot and halving the probability of winning the amount in the pot (half because you get the pot on a tail but not a head), until we reach the limit."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [],
   "source": [
    "def st_pete(limit):\n",
    "    \"Return the probability distribution for the St. Petersburg Paradox with a limited bank.\"\n",
    "    P = {}     # The probability distribution\n",
    "    pot = 2    # Amount of money in the pot\n",
    "    pr  = 1/2. # Probability that you end up with the amount in pot\n",
    "    while pot < limit:\n",
    "        P[pot] = pr\n",
    "        pot    = pot * 2\n",
    "        pr     = pr / 2\n",
    "    P[limit] = pr * 2     # pr * 2 because you get limit for heads or tails\n",
    "    return ProbDist(P)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "Let's try with the casino limited to 100 million dollars:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{2: 0.5,\n",
       " 4: 0.25,\n",
       " 8: 0.125,\n",
       " 16: 0.0625,\n",
       " 32: 0.03125,\n",
       " 64: 0.015625,\n",
       " 128: 0.0078125,\n",
       " 256: 0.00390625,\n",
       " 512: 0.001953125,\n",
       " 1024: 0.0009765625,\n",
       " 2048: 0.00048828125,\n",
       " 4096: 0.000244140625,\n",
       " 8192: 0.0001220703125,\n",
       " 16384: 6.103515625e-05,\n",
       " 32768: 3.0517578125e-05,\n",
       " 65536: 1.52587890625e-05,\n",
       " 131072: 7.62939453125e-06,\n",
       " 262144: 3.814697265625e-06,\n",
       " 524288: 1.9073486328125e-06,\n",
       " 1048576: 9.5367431640625e-07,\n",
       " 2097152: 4.76837158203125e-07,\n",
       " 4194304: 2.384185791015625e-07,\n",
       " 8388608: 1.1920928955078125e-07,\n",
       " 16777216: 5.960464477539063e-08,\n",
       " 33554432: 2.9802322387695312e-08,\n",
       " 67108864: 1.4901161193847656e-08,\n",
       " 100000000: 1.4901161193847656e-08}"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "StP = st_pete(limit=10**8)\n",
    "StP"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "Now we define the function `EV` to compute the [expected value](https://en.wikipedia.org/wiki/Expected_value) of a probability distribution: "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [],
   "source": [
    "def EV(P):\n",
    "    \"The expected value of a probability distribution.\"\n",
    "    return sum(P[v] * v \n",
    "               for v in P)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "27.490116119384766"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "EV(StP)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "This says that for a casino with a bankroll of 100 million dollars, if you want to maximize your expected value, you should be willing to pay up to $27.49 to play the game. Would you pay that much? I wouldn't, and neither would Daniel Bernoulli. \n",
    "\n",
    "## Response 2: Value of Money\n",
    "\n",
    "Daniel Bernoulli came up with a second response to the paradox based on the idea that if you have a lot of money, then additional money becomes less valuable to you. If I had nothing, and I won $1000, I would be very happy. But if I already had a million dollars and I won $1000, it would be less valuable. How much less valuable? Bernoulli proposed, and [experiments confirm](https://books.google.com/books?id=1oEa-BiARWUC&pg=PA205&lpg=PA205&dq=mr+beard+oil+wildcatter+value+of+money+utility&source=bl&ots=cBDIX-rkTz&sig=GHB8-inorWrU39vA8JYV_sCtqB8&hl=en&sa=X&ved=0CCAQ6AEwAGoVChMI5fu-p8qlyAIViKWICh0XAAz5#v=onepage&q=mr%20beard%20oil%20wildcatter%20value%20of%20money%20utility&f=false), that *the value of money is roughly logarithmic.* That is, rational bettors don't try to maximize their expected monetary value, they try to maximize their *expected utility*: the amount of \"happiness\" that the money is worth.\n",
    "I'll write the function `util` to describe what a dollar amount is worth to a hypothetical gambler. `util` says that a dollar is worth a dollar, until the amount is \"enough\" money. After that point, each additional dollar is worth half as much (only brings half as much happiness). Value keeps accumulating at this rate until we reach the next threshold of \"enough,\" when the utility of additional dollars is halfed again. The exact details of `util` are not critical; what matters is that overall money becomes less valuable after we have won a lot of it."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [],
   "source": [
    "def util(dollars, enough=1000): \n",
    "    \"The value of money: only half as valuable after you already have enough.\"\n",
    "    if dollars < enough:\n",
    "        return dollars\n",
    "    else:\n",
    "        additional = dollars-enough\n",
    "        return enough + util(additional / 2, enough * 2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "A table and a plot will give a feel for the `util` function. Notice the characteristics concave-down shape of the plot."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "            100 $ =        100 util\n",
      "          1,000 $ =      1,000 util\n",
      "         10,000 $ =      4,250 util\n",
      "        100,000 $ =     15,937 util\n",
      "      1,000,000 $ =     51,593 util\n",
      "     10,000,000 $ =    162,460 util\n",
      "    100,000,000 $ =    535,646 util\n",
      "  1,000,000,000 $ =  1,658,229 util\n"
     ]
    }
   ],
   "source": [
    "for d in range(2, 10):\n",
    "    m = 10 ** d\n",
    "    print('{:15,d} $ = {:10,d} util'.format(m, int(util(m))))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Y axis is util(x); x axis is in thousands of dollars.\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZcAAAEACAYAAAB/BTv2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3X2Y1XWd//HnSxTRRPLmQlYQb1ZQMM1IoTRj0hCl1rtW\npW0Fjf3tFepq3iXYXoFruWH2E83Fy01ScClCs5+kBGg43iIg3kwBwpQpMAQl4JSZyMD798fnO8xh\nFjxzc2bOmTmvx3V59Z33+X6/5/P9pvOez70iAjMzs0Lao9gFMDOzzsfJxczMCs7JxczMCs7JxczM\nCs7JxczMCs7JxczMCi5vcpE0VdIGSVU5sY9LWijpFUmLJZ2U89l4SdWSVkg6Myc+SFKVpFWSJufE\nu0qamV2zUFLfnM9GZ+evlDSqMI9sZmZtrSk1l/uB4Y1itwETIuITwATgewCSBgIXAQOAs4EpkpRd\ncw8wJiL6A/0l1d9zDLApIvoBk7N7I+kA4FvAycAQYIKkHi16SjMza1d5k0tEPAdsbhTeDtT/ov8o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8F3k6FnAZ99xTURsA96RdGC+AnT0\n5FI2JO1H+qvh6qwG03gkRqcfmSHpC8CGrCb3YWPzO/27IDVrDAL+KyIGAX8FxlGe/158lPTX9eGk\nJrKPSPoKZfguPkQhn71J82I6enKpAXI7l/pksU4lq+o/DDwYEY9m4Q2SDsk+7wX8MYvXAIflXF7/\nTnYX70hOBc6R9AbwE+B0SQ8C68vwXawF1kTES9nPPyMlm3L89+LzwBsRsSn7y/rnwCmU57uoV8hn\n3/FZNu9w/4jYlK8AHT25LAGOlnS4pK7ASGB2kcvUFn4ELI+IO3Nis4FLs+PRwKM58ZHZCI8jgaOB\nxVnVuFbSYEkCRuVc0yFExE0R0TcijiL9f70gIi4BfkH5vYsNwBpJ/bPQGcAyyvDfC1Jz2Kckdcue\n4QxgOeX1LsTONYpCPvvs7B4AFwILmlSiYo90KMBIibNII6iqgXHFLk8bPN+pwDbSSLhXgJezZz4Q\neDJ79vnAR3OuGU8aBbICODMn/kng19m7urPYz9bK9zKUhtFiZfkugI+T/sB6FXiENFqsXN/FhOy5\nqkidz3uVy7sAfgysA7aQEu1lwAGFenZgb2BWFn8ROKIp5fIkSjMzK7iO3ixmZmYlyMnFzMwKzsnF\nzMwKzsnFzMwKzsnFzMwKzsnFzMwKzsnFzMwKzsnFzMwK7v8D8CRqVYjz3MoAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x108f149b0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%matplotlib inline \n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "plt.plot([util(x) for x in range(1000, 10000000, 1000)])\n",
    "print('Y axis is util(x); x axis is in thousands of dollars.')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "Now I will define the function `EU`, which computes the [expected utility](http://wiki.lesswrong.com/wiki/Expected_utility) of the game:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [],
   "source": [
    "def EU(P, U):\n",
    "    \"The expected utility of a probability distribution, given a utility function.\"\n",
    "    return sum(P[e] * U(e) \n",
    "               for e in P)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "13.096907431492582"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "EU(StP, util)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "That says we should pay up to $13.10 to play the game, which sounds more reasonable than $27.49.\n",
    "\n",
    "# Understanding St. Petersburg  through Simulation\n",
    "\n",
    "Before I plunk down my $13, I'd like to understand the game better. I'll write a simulation of the game:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {
    "button": false,
    "collapsed": true,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [],
   "source": [
    "def flip(): return random.choice(('head', 'tail'))\n",
    "\n",
    "def simulate_st_pete(limit=10**9):\n",
    "    \"Simulate one round of the St. Petersburg game, and return the payoff.\"\n",
    "    pot = 2\n",
    "    while flip() == 'head':\n",
    "        pot = pot * 2\n",
    "        if pot > limit:\n",
    "            return limit\n",
    "    return pot"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "I will run the simulation 100,000 times (with a random seed specified for reproducability) and make the results into a probability distribution:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{2: 0.49755,\n",
       " 4: 0.2506,\n",
       " 8: 0.1259,\n",
       " 16: 0.06322,\n",
       " 32: 0.03151,\n",
       " 64: 0.01607,\n",
       " 128: 0.00751,\n",
       " 256: 0.0037,\n",
       " 512: 0.00191,\n",
       " 1024: 0.00106,\n",
       " 2048: 0.00045,\n",
       " 4096: 0.00029,\n",
       " 8192: 0.0001,\n",
       " 16384: 6e-05,\n",
       " 32768: 5e-05,\n",
       " 65536: 1e-05,\n",
       " 1048576: 1e-05}"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.seed(123456)\n",
    "\n",
    "results = ProbDist(Counter(simulate_st_pete() for _ in range(100000)))\n",
    "results"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "The results are about what you would expect: about half the pots are 2, a quarter are 4, an eighth are 8, and higher pots are more and more unlikely.  Let's check expected utility and expected value:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(13.2477575, 26.71606)"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "EU(results, util), EV(results)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "These are not too far off from the theoretial values.\n",
    "\n",
    "To see better how things unfold, I will define a function to plot the running average of repeated rounds:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [],
   "source": [
    "def running_averages(iterable):\n",
    "    \"For each element in the iterable, yield the mean of all elements seen so far.\" \n",
    "    total, n = 0, 0\n",
    "    for x in iterable:\n",
    "        total, n = total + x, n + 1\n",
    "        yield total / n\n",
    "\n",
    "def plot_running_averages(fn, n):\n",
    "    \"Plot the running average of calling the function n times.\"\n",
    "    plt.plot(list(running_averages(fn() for _ in range(n))))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "Let's do ten repetitions of plotting the running averages of 100,000 rounds:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYcAAAEACAYAAABYq7oeAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3Xd4VFX++PH3mZ5JT0ghvRACJPQiIEpEUMSOrt1V2bWs\n9bera/nqKu66qOiurqvrsurade1dFFCDDUQIvRMgPSGF9Ew/vz9OAkjoKZOE83qeeTJzM3fumUnm\nfu75nCaklGiapmnavgz+LoCmaZrW8+jgoGmaprWjg4OmaZrWjg4OmqZpWjs6OGiapmnt6OCgaZqm\ntXPY4CCEeEEIUSGEWLPPtrlCiI1CiFVCiPeEECH7/O4eIcTW1t+f1lUF1zRN07rOkdQcXgRO32/b\nAiBLSjkC2ArcAyCEGAJcBAwGzgD+JYQQnVdcTdM0rTscNjhIKb8Hdu+3bZGU0tf6cCmQ0Hr/HOB/\nUkqPlHInKnCM67ziapqmad2hM9ocZgGft96PB4r2+V1J6zZN0zStF+lQcBBC3Au4pZRvdlJ5NE3T\ntB7AdKw7CiGuBmYAU/bZXAIk7vM4oXXbgfbXkzppmqYdAylll7flHmnNQbTe1AMhpgN/BM6RUjr3\ned7HwCVCCIsQIhUYACw72ItKKfVNSh544AG/l6Gn3PRnoT8L/Vkc+tZdDltzEEK8AeQAkUKIQuAB\n4P8AC7CwtTPSUinljVLKDUKIt4ENgBu4UXbnu9E0Td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Sb70q0SK4NxghRAq4Ffi8lLLESxtHXub8dd3uDfytNwwhxBlAr5RyPa+e\nx3e8LAjfkJcBP5BSLgPKhG+Fk7Fe5Ai30ZlB2ItICiFWMAll8Sq8Zco+EcphLzB+kqitFve2Rwih\nESqGX0gp76xF9wohmmvftwB9tfi9wLRxl++TwyvFv+QaEa4lyUgphw5CUV4v7wbOFELsAG4BThJC\n/ALomYSy2APsllKurZ3/mlBZTMZ6cQqwQ0o5VHuzvR04lskpi328GWX/H7W5E6EcngLmCCFmCCEM\nwvGwuyYgHweDnxKOB353XNxdwKdq4fOBO8fF/3XNwmAmMAd4sta1HBFCHCmEEMAn/+Sa82vhjwEP\nHrSSvA6klF+UUk6XUs4i/H8flFKeB9zN5JNFL7BbCDGvFnUysIVJWC8Ih5OOFkLEamU4GXiWySUL\nwUvf6N+Mst8HnCpCq7k64NRa3KszQZMypxFa82wDrproSaI3qEzvBnxC66tngHW1ctYDD9TKez+Q\nG3fN1YRWCFuB946LPwzYVJPPd8fFm8CqWvwTQPtEl/s1yOUE9k9IT0pZAEsJX4rWA7cRWo1MVll8\npVaujcDPCS0WJ4UsgJuBLsAmVJQXEE7OH/SyEyqgbcALwCdfS36jRXAREREREQcQTUhHRERERBxA\npBwiIiIiIg4gUg4REREREQcQKYeIiIiIiAOIlENERERExAFEyiEiIiIi4gAi5RARERERcQCRcoiI\niIiIOID/DzOM3GEve64NAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1031ad128>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "random.seed('running')\n",
    "\n",
    "for i in range(10):\n",
    "    plot_running_averages(simulate_st_pete, 100000);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "What can we see from this?  Nine of the 10 repetitions have a final expected value payoff (after 100,000 rounds) between 10 and 35. So a price around $13 still seems reasonable. One outlier has an average payoff just over 100, so if you are feeling lucky you might be willing to pay more than $13.\n",
    "\n",
    "# The Ellsburg Paradox\n",
    "\n",
    "The [Ellsburg Paradox](https://en.wikipedia.org/wiki/Ellsberg_paradox) has it all: an urn problem; a paradox; a conclusion that can only be resolved through psychology, not  mathematics alone; and a colorful history with an inventor, [Daniel Ellsburg](https://en.wikipedia.org/wiki/Daniel_Ellsberg), who went on to become the releaser of the [Pentagon Papers](https://en.wikipedia.org/wiki/Pentagon_Papers).  The paradox is as follows:\n",
    "\n",
    "> An urn contains 33 red balls and 66 other balls that are either black or yellow. You don't know the mix of black and yellow, just that they total 66. A single ball is drawn at random. You are asked which of these two gambles you would prefer:\n",
    "- **R**: Win 100 for a red ball.\n",
    "- **B**: Win 100 for a black ball.\n",
    "\n",
    "> Separately, you are also asked which of these two gambles you prefer:\n",
    "- **RY**: Win 100 for a red or yellow ball.\n",
    "- **BY**: Win 100 for a black or yellow ball.\n",
    "\n",
    "Many people reason as follows: \n",
    "- **R**: I win 1/3 of the time\n",
    "- **B**: I win somewhere between 0 and 2/3 of the time, but I'm not sure of the probability. \n",
    "- **RY**: I win at least 1/3 of the time and maybe up to 100% of the time; I'm not sure. \n",
    "- **BY**: I win 2/3 of the time. \n",
    "- Overall, I prefer the relative certainty of **R** over **B** and of **BY** over **RY**.\n",
    "\n",
    "The paradox is that, from an expected utility point of view, that reasoning is inconsistent, no matter what the mix of black and yellow balls is (or no matter what you believe the mix might be).  **RY** and **BY** are just the same gambles as **R** and **B**, but with an additional 100 for a yellow ball. So if you prefer **R** over **B**, you should prefer **RY** over **BY** (and if you prefer **B** over **R** you should prefer **BY** over **RY**), for any possible mix of black and yellow balls.\n",
    "\n",
    "Let's demonstrate. For each possible number of black balls (on the *x* axis), we'll plot the expected value of each of the four gambles; **R** as a solid red line, **B** as a solid black line, **RY** as a dotted red line, and **BY** as a dotted black line:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {
    "run_control": {}
   },
   "outputs": [
    {
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SklCRESS\n+v93Q77WPQv5rgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x10b3ad0b8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "def ellsburg():\n",
    "    show('R', 'r')\n",
    "    show('B', 'k')\n",
    "    show('RY', 'r:')\n",
    "    show('BY', 'k:')\n",
    "    plt.xlabel('Number of black balls')\n",
    "    plt.ylabel('Expected value of each gamble')\n",
    "    \n",
    "blacks   = list(range(67))\n",
    "all_urns = [Counter(R=33, B=b, Y=66-b) for b in blacks]\n",
    "    \n",
    "def show(colors, line):\n",
    "    scores = [score(colors, urn) for urn in all_urns]\n",
    "    plt.plot(blacks, scores, line)\n",
    "    \n",
    "def score(colors, urn): return sum(urn[c] for c in colors)\n",
    "\n",
    "ellsburg()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "run_control": {}
   },
   "source": [
    "We see that for any number of black balls up to 33, the solid red line is above the solid black line, which means **R** is better than **B**. The two gambles are equal with 33 black balls, and from there on, **B** is better than **R**.\n",
    "\n",
    "Similarly, up to 33 black balls, the dashed red line is above the dashed black line, so **RY** is better than **BY**. They are equal at 33, and after that, **BY** is better than **RY**. So in summary, **R** > **B** if and only if **RY** > **BY**.\n",
    "\n",
    "It is pretty clear that this holds for every possible mix of black and yellow balls, taken one at a time. But what if you believe that the mix might be one of several possibilities? For example, if we assume that any number of black balls from 0 to 66 is equally likely, then we can use a function, `expected_score` to give the expected return for a gamble (as specified by the colors in the gamble), averaged over a collection of possible urns, each with a different black/yellow mix:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "R  33.0\n",
      "B  33.0\n",
      "RY 66.0\n",
      "BY 66.0\n"
     ]
    }
   ],
   "source": [
    "def expected_score(colors, urns): \n",
    "    return sum(score(colors, urn) for urn in urns) / len(urns)\n",
    "\n",
    "def compare(urns):\n",
    "    for colors in ('R', 'B', 'RY', 'BY'):\n",
    "        print(colors.ljust(2), expected_score(colors, urns))\n",
    "        \n",
    "compare(all_urns)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "run_control": {}
   },
   "source": [
    "This says that **B** and **R** have an equal expected return, as do  **BY** and **RY**.\n",
    "\n",
    "Now imagine that you believe that any mix is possible, but that a majority of black balls is more likely, in particular that the urns in the second half of the list of `all_urns` are twice as likely as those in the first half. Then we will see that **B** > **R** and **BY** > **RY**:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "R  33.0\n",
      "B  38.554455445544555\n",
      "RY 60.445544554455445\n",
      "BY 66.0\n"
     ]
    }
   ],
   "source": [
    "compare(all_urns[:33] + 2 * all_urns[33:])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "run_control": {}
   },
   "source": [
    "If we believe the first half of the list (with fewer black balls) is twice as likely, we get this:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "R  33.0\n",
      "B  27.39\n",
      "RY 71.61\n",
      "BY 66.0\n"
     ]
    }
   ],
   "source": [
    "compare(2 * all_urns[:33] + all_urns[33:])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "run_control": {}
   },
   "source": [
    "This time the preferences are reversed for both gambles, **R** > **B** and **RY** > **BY**."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "run_control": {}
   },
   "source": [
    "So why do many people prefer **R** > **B** and **BY** > **RY**? One explanation is *risk aversion*; it feels safer to take a definite 1/3 chance of winning, rather than a gamble that might be as good as 2/3, but might be as bad as 0. This is irrational thinking (in the sense that those who follow this strategy will win less), but people are sometimes irrational."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "run_control": {}
   },
   "source": [
    "# Simpson's Paradox\n",
    "\n",
    "This has nothing to do with the TV show. D'oh! In 1951, statistician [Edward Simpson](https://en.wikipedia.org/wiki/Edward_H._Simpson) (who worked with Alan Turing at Bletchley Park during World War II), noted that it is possible to take a sample space in which **A** is better than **B**, and split it into two groups, such that **B** is better than **A** in both groups.  \n",
    "\n",
    "For example, here is data from trials of two treatments for kidney stones, **A** and **B**, separated into two subgroups or cases: first, for small kidney stones, and second for large ones. In all cases we record the number of good and bad outcomes of the treatment:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Good and bad outcomes for kidney stone treatments A and B,\n",
    "# each in two cases: [small_stones, large_stones]\n",
    "A = [Counter(good=81,  bad=6),  Counter(good=192, bad=71)]\n",
    "B = [Counter(good=234, bad=36), Counter(good=55, bad=25)]\n",
    "\n",
    "def success(case): return ProbDist(case)['good']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "run_control": {}
   },
   "source": [
    "Let's compare probabilities of success:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0.9310344827586207, 0.7300380228136882]"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[success(case) for case in A]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {
    "run_control": {}
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0.8666666666666667, 0.6875]"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[success(case) for case in B]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "run_control": {}
   },
   "source": [
    "We see that for small stones, **A** is better, 93% to 87%, and for large stones, **A** is also better, 75% to 69%. So **A** is better no matter what, right?\n",
    "\n",
    "Not so fast.\n",
    "\n",
    "We can add up `Counter`s to get the overall success rate for **A** and **B**, over all cases:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {
    "run_control": {}
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.78"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "success(A[0] + A[1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {
    "run_control": {}
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.8257142857142857"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "success(B[0] + B[1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "run_control": {}
   },
   "source": [
    "Overall, **B** is more successful, 83% to 78%, even though **A** is better in both cases. So if you had kidney stones, and you want the highest chance of success, which treatment would you prefer? If you knew you had small stones (or large stones), the evidence supports **A**. But if the size was unknown, does that mean you should prefer **B**? Analysts agree that the answer is no, you should stick with **A**. The only reason why **B** has a higher overall success rate is that doctors choose to do **B** more often on the easier, small stone cases, and reserve **A** for the harder, large stone cases. **A** is better, but it has a lower overall percentage because it is given the difficult patients.\n",
    "\n",
    "Here's another example, showing the batting averages for two baseball players, Derek Jeter and David Justice, for the years 1995 and 1996 (I should say that Justice is considered a very good player, but Jeter is considered even better, a sure-bet future Hall of Fame player):"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {
    "run_control": {}
   },
   "outputs": [],
   "source": [
    "Jeter   = [Counter(hit=12,  out=36),  Counter(hit=183, out=399)]\n",
    "Justice = [Counter(hit=104, out=307), Counter(hit=45,  out=95)]\n",
    "\n",
    "def BA(case): \"Batting average\"; return ProbDist(case)['hit']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {
    "run_control": {}
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0.25, 0.31443298969072164]"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[BA(year) for year in Jeter]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {
    "run_control": {}
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0.25304136253041365, 0.32142857142857145]"
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[BA(year) for year in Justice]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "run_control": {}
   },
   "source": [
    "So Justice had a higher batting average than Jeter for both 1995 and 1996.  Let's check overall:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {
    "run_control": {}
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.30952380952380953"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "BA(Jeter[0] + Jeter[1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {
    "run_control": {}
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.27041742286751363"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "BA(Justice[0] + Justice[1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "run_control": {}
   },
   "source": [
    "Overall, Jeter had a significantly higher batting average.  How did Jeter manage to do worse both years, then? Because in 1995, Jeter was injured for much of the year, and his low batting average was over a small number of at-bats. In 1996, Jeter was healthy, but Justice was injured for much of the year; however he managed a high average in his few at-bats.\n",
    "\n",
    "For the kidney stone data, we trust the individual cases, not the overall, because there are biases that lead to patients being assigned to one treatment or the other. For the batting average data, we trust the overall numbers, because there are no such biases, and because larger numbers lead to a closer approximation to a true value. The data alone can't tell you what to believe; you need the story (and the model) behind the data as well."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "button": false,
    "new_sheet": false,
    "run_control": {
     "read_only": false
    }
   },
   "source": [
    "# Conclusion\n",
    "\n",
    "We've seen how to manage probability paradoxes. Just be explicit about what the problem says, and then methodical about defining the sample space, and finally be careful in counting the number of outcomes in the numerator and denominator.  But the bigger lesson is: treat those around you as reasonable people, and when they have different opinions, try to discover what problem they are  solving.\n",
    "\n",
    "*Note*: Mohammed El-Beltagy created a very nice [translation of an earlier version of this page to Julia](http://nbviewer.ipython.org/gist/mbeltagy/3ba5f77da6382da192c3). \n",
    "."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
