{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true,
"tags": [
"remove_cell"
]
},
"outputs": [],
"source": [
"# HIDDEN\n",
"from datascience import *\n",
"from prob140 import *\n",
"%matplotlib inline\n",
"import matplotlib.pyplot as plt\n",
"plt.style.use('fivethirtyeight')\n",
"import numpy as np"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## More Examples ##"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"Just a plus rule and a times rule – that's all it takes to get going. Here are some examples of standard problem solving techniques."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Example 1: A Fundamental Method – Start by Partitioning ###\n",
"A box contains 6 dark chocolates and 4 milk chocolates. I pick two at random without replacement.\n",
"\n",
"**Question.** What is the chance that I get one of each kind?\n",
"\n",
"**Answer.** You will have noticed that the problem doesn't specify whether the dark has to come first, or the milk. Either could happen. So list the distinct ways the event can happen, that is, partition the event:\n",
"- first dark then milk: chance $(6/10)\\cdot(4/9)$ by the multiplication rule\n",
"- first milk then dark: chance $(4/10)\\cdot(6/9)$\n",
"\n",
"(Aha! The two terms are equal! Get ready for many more such symmetries in sampling without replacement.)\n",
"\n",
"Now add the chances of the two bits. The answer is $2\\cdot(6/10)\\cdot(4/9)$.\n",
"\n",
"This method should become as natural as breathing. You should also redo the problem under the unnatural assumption that the chocolates are drawn with replacement, to see what changes and what stays the same."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Example 2: Polya's Urn Scheme ###\n",
"A box contains $b$ black balls and $w$ white balls. A ball is drawn at random, and then replaced in the urn along with $d$ more balls of its color. Then a ball is drawn at random from the urn.\n",
"\n",
"**Question 1.** What is the chance that the first ball drawn is black?\n",
"\n",
"**Answer 1.** Not much effort required.\n",
"\n",
"$$\n",
"P(\\text{first ball black}) = \\frac{b}{b+w}\n",
"$$\n",
"\n",
"**Question 2.** What is the chance that the second ball drawn is black?\n",
"\n",
"**Answer 2.** Your mind goes naturally to what the first ball was, so partition according to the color of that one, and add. The fundamental method strikes again.\n",
"\n",
"$$\n",
"\\begin{align*}\n",
"P(\\text{second ball black}) &= P(WB) + P(BB) \\\\ \\\\\n",
"&= \\frac{w}{b+w} \\cdot \\frac{b}{b+w+d} ~+~ \\frac{b}{b+w} \\cdot \\frac{b+d}{b+w+d} \\\\ \\\\\n",
"&= \\frac{wb + b^2 + bd}{(b+w)(b+w+d)} \\\\ \\\\\n",
"&= \\frac{b(b+w+d)}{(b+w)(b+w+d)} \\\\ \\\\\n",
"&= \\frac{b}{b+w}\n",
"\\end{align*}\n",
"$$\n",
"\n",
"That's the same as the chance that the first ball is black, no matter what $d$ is. This scheme is interesting!\n",
"\n",
"**Question 3.** What is the chance that the second ball drawn is black, given that the first one drawn was black?\n",
"\n",
"**Answer 3.** We already used this in the calculation above. Conditional probabilities \"going forwards in time\" can often just be read off the information in the question, as in this case:\n",
"\n",
"$$\n",
"P(\\text{second ball black} \\mid \\text{first ball black}) =\n",
"\\frac{b+d}{b+w+d}\n",
"$$\n",
"\n",
"**Question 4.** What is the chance that the first ball drawn is black, given that the second one drawn was black?\n",
"\n",
"**Answer 4.** This kind of \"going back in time\" conditional probability isn't easy to just read off. **This is where the division rule comes in.**\n",
"\n",
"$$\n",
"\\begin{align*}\n",
"P(\\text{first ball black} \\mid \\text{second ball black}) &=\n",
"\\frac{P(BB)}{P(\\text{second ball black})} \\\\ \\\\\n",
"&= \\frac{\\frac{b}{b+w} \\cdot \\frac{b+d}{b+w+d}}{\\frac{b}{b+w}} \\\\ \\\\\n",
"&= \\frac{b+d}{b+w+d}\n",
"\\end{align*}\n",
"$$\n",
"\n",
"This one does depend on $d$, but it's the same as Answer 3. Forwards and backwards don't seem to make a difference. \n",
"\n",
"Now you begin to see why this scheme carries the name of its renowned originator [George Polya](https://en.wikipedia.org/wiki/George_Pólya) (1887-1985). You can keep repeating the scheme – replace the drawn ball with another $d$ balls of its color, and draw again – to get a *process* with beautiful and useful properties for updating opinions as data comes in. We'll see that later in the course."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"anaconda-cloud": {},
"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.8.3"
}
},
"nbformat": 4,
"nbformat_minor": 1
}