Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
norvig authored Feb 9, 2020
1 parent c6cc03d commit ad9fa3e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions ipynb/ProbabilityParadox.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2249,7 +2249,7 @@
}
},
"source": [
"A table and a plot will give a feel for the `util` function. Notice the characteristics concave-down shape of the plot."
"A table and a plot will give a feel for the `util` function. Notice the characterisitc concave-down shape of the plot."
]
},
{
Expand Down Expand Up @@ -3094,7 +3094,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.3"
"version": "3.7.0"
}
},
"nbformat": 4,
Expand Down
22 changes: 11 additions & 11 deletions ipynb/ProbabilitySimulation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@
"- $A$, $B$: the cutoff values they choose: the lower bound of the range of first numbers they will accept.\n",
"- $a$, $b$: the actual random numbers that appear on the screen.\n",
"\n",
"For example, if player** A** chooses a cutoff of $A$ = 0.6, that means that** A** would accept any first number greater than 0.6, and reject any number below that cutoff. The question is: What cutoff, $A$, should player** A** choose to maximize the chance of winning, that is, maximize P($a$ > $b$)?\n",
"For example, if player **A** chooses a cutoff of $A$ = 0.6, that means that **A** would accept any first number greater than 0.6, and reject any number below that cutoff. The question is: What cutoff, $A$, should player **A** choose to maximize the chance of winning, that is, maximize P($a$ > $b$)?\n",
"\n",
"First, simulate the number that a player with a given cutoff gets (note that `random.random()` returns a float sampled uniformly from the interval [0..1]):"
]
Expand Down Expand Up @@ -630,11 +630,11 @@
"\n",
"## The Hot New Game Show Problem: Exact Calculation\n",
"\n",
"More promising is the possibility of making `Pwin(A, B)` an exact calculation. But before we get to `Pwin(A, B)`, let's solve a simpler problem: assume that both players** A** and** B** have chosen a cutoff, and have each received a number above the cutoff. What is the probability that** A** gets the higher number? We'll call this `Phigher(A, B)`. We can think of this as a two-dimensional sample space of points in the ($a$, $b$) plane, where$a$ ranges from the cutoff $A$ to 1 and $b$ ranges from the cutoff B to 1. Here is a diagram of that two-dimensional sample space, with the cutoffs $A$=0.5 and $B$=0.6:\n",
"More promising is the possibility of making `Pwin(A, B)` an exact calculation. But before we get to `Pwin(A, B)`, let's solve a simpler problem: assume that both players **A** and **B** have chosen a cutoff, and have each received a number above the cutoff. What is the probability that **A** gets the higher number? We'll call this `Phigher(A, B)`. We can think of this as a two-dimensional sample space of points in the ($a$, $b$) plane, where$a$ ranges from the cutoff $A$ to 1 and $b$ ranges from the cutoff B to 1. Here is a diagram of that two-dimensional sample space, with the cutoffs $A$=0.5 and $B$=0.6:\n",
"\n",
"<img src=\"http://norvig.com/ipython/probability2da.jpg\" width=413>\n",
"\n",
"The total area of the sample space is 0.5 &times; 0.4 = 0.20, and in general it is (1 - $A$) &middot; (1 - $B$). What about the favorable cases, where**&nbsp;A** beats**&nbsp;B**? That corresponds to the shaded triangle below:\n",
"The total area of the sample space is 0.5 &times; 0.4 = 0.20, and in general it is (1 - $A$) &middot; (1 - $B$). What about the favorable cases, where **A** beats **B**? That corresponds to the shaded triangle below:\n",
"\n",
"<img src=\"http://norvig.com/ipython/probability2d.jpg\" width=413>\n",
"\n",
Expand Down Expand Up @@ -694,16 +694,16 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We're now ready to tackle the full game. There are four cases to consider, depending on whether**&nbsp;A** and**&nbsp;B** gets a first number that is above or below their cutoff choices:\n",
"We're now ready to tackle the full game. There are four cases to consider, depending on whether **A** and **B** gets a first number that is above or below their cutoff choices:\n",
"\n",
"| first $a$ | first $b$ | P($a$, $b$) | P(A wins &vert; $a$, $b$) | Comment |\n",
"| first $a$ | first $b$ | P($a$, $b$) | P(A wins $a$, $b$) | Comment |\n",
"|:-----:|:-----:| ----------- | ------------- | ------------ |\n",
"|$a$ > $A$ | $b$ > $B$ | (1 - $A$) &middot; (1 - $B$) | Phigher(*A*, $B$) | Both above cutoff; both keep first numbers |\n",
"|$a$ < $A$ | $b$ < $B$ | $A$ &middot; $B$ | Phigher(0, 0) | Both below cutoff, both get new numbers from [0..1] |\n",
"|$a$ > $A$ | $b$ < $B$ | (1 - $A$) &middot; $B$ | Phigher(*A*, 0) |**&nbsp;A** keeps number;**&nbsp;B** gets new number from [0..1] |\n",
"|$a$ < $A$ | $b$ > $B$ | $A$ &middot; (1 - $B$) | Phigher(0, $B$) |**&nbsp;A** gets new number from [0..1];**&nbsp;B** keeps number |\n",
"|$a$ > $A$ | $b$ < $B$ | (1 - $A$) &middot; $B$ | Phigher($A$, 0) | **A** keeps number; **B** gets new number from [0..1] |\n",
"|$a$ < $A$ | $b$ > $B$ | $A$ &middot; (1 - $B$) | Phigher(0, $B$) | **A** gets new number from [0..1]; **B** keeps number |\n",
"\n",
"For example, the first row of this table says that the event of both first numbers being above their respective cutoffs has probability (1 - $A$) &middot; (1 - $B$), and if this does occur, then the probability of**&nbsp;A** winning is Phigher(*A*, $B$).\n",
"For example, the first row of this table says that the event of both first numbers being above their respective cutoffs has probability (1 - $A$) &middot; (1 - $B$), and if this does occur, then the probability of **A** winning is Phigher(*A*, $B$).\n",
"We're ready to replace the old simulation-based `Pwin` with a new calculation-based version:"
]
},
Expand Down Expand Up @@ -936,7 +936,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"What does this [Pringle of Probability](http://fivethirtyeight.com/features/should-you-shoot-free-throws-underhand/) show us? The highest win percentage for**&nbsp;A**, the peak of the surface, occurs when $A$ is around 0.5 and $B$ is 0 or 1. We can confirm that, finding the maximum `Pwin(A, B)` for many different cutoff values of `A` and `B`:"
"What does this [Pringle of Probability](http://fivethirtyeight.com/features/should-you-shoot-free-throws-underhand/) show us? The highest win percentage for **A**, the peak of the surface, occurs when $A$ is around 0.5 and $B$ is 0 or 1. We can confirm that, finding the maximum `Pwin(A, B)` for many different cutoff values of `A` and `B`:"
]
},
{
Expand Down Expand Up @@ -1004,7 +1004,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"And what if we run it the other way around, where**&nbsp;B** chooses a cutoff first, and then**&nbsp;A** responds?"
"And what if we run it the other way around, where **B** chooses a cutoff first, and then **A** responds?"
]
},
{
Expand Down Expand Up @@ -1033,7 +1033,7 @@
"metadata": {},
"source": [
"In both cases, the rational choice for both players is a cutoff of 0.618034, which corresponds to the \"saddle point\" in the middle of the plot. This is a *stable equilibrium*; consider fixing $B$ = 0.618034, \n",
"and notice that if $A$ changes to any other value, we slip off the saddle to the right or left, resulting in a worse win probability for**&nbsp;A**. Similarly, if we fix $A$ = 0.618034, then if $B$ changes to another value, we ride up the saddle to a higher win percentage for**&nbsp;A**, which is worse for**&nbsp;B**. So neither player will want to move from the saddle point.\n",
"and notice that if $A$ changes to any other value, we slip off the saddle to the right or left, resulting in a worse win probability for **A**. Similarly, if we fix $A$ = 0.618034, then if $B$ changes to another value, we ride up the saddle to a higher win percentage for **A**, which is worse for **B**. So neither player will want to move from the saddle point.\n",
"\n",
"The moral for continuous spaces is the same as for discrete spaces: be careful about defining your sample space; measure carefully, and let your code take care of the rest."
]
Expand Down

0 comments on commit ad9fa3e

Please sign in to comment.