Add files via upload

This commit is contained in:
Peter Norvig 2018-04-13 14:42:07 -07:00 committed by GitHub
parent 8e56e194bf
commit b3bd3a665b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,7 +8,7 @@
"\n",
"## 12 April, 2018\n",
"\n",
"\"It's tough to make predictions, especially [about](https://en.wikiquote.org/wiki/Yogi_Berra) [the](https://en.wikiquote.org/wiki/Niels_Bohr) future.\" That's true for the **NBA basketball playoffs**, where the Rockets are the favorites, with a 44% chance of winning the title according to [538](https://fivethirtyeight.com/features/the-nba-playoffs-sleepers-favorites-and-best-first-round-matchups/), and 35% according to the Las Vegas oddsmakers, a relatively small difference of opinion. But there are some big discrepancies: the Warriors are tied with the Rockets at 35% according to Vegas, but stand at only 4% according to 538. That 9-fold difference underscores that rational people can use different models with different assumptions and come to different conclusions. Here are some models you might choose:\n",
"\"It's tough to make predictions, especially [about](https://en.wikiquote.org/wiki/Yogi_Berra) [the](https://en.wikiquote.org/wiki/Niels_Bohr) future.\" That's true for the **NBA basketball playoffs**, where there is a difference of opinion over the probable fates of the Warriors and Cavs, the teams that met in the finals each of the last three years. The Las Vegas oddsmakers have the Warriors as co-favorites at 35% chance to win the title, while [538](https://fivethirtyeight.com/features/the-nba-playoffs-sleepers-favorites-and-best-first-round-matchups/), using their ELO rating, give the Warriors only a 4% chance. That 9-fold difference underscores that rational people can use different models with different assumptions and come to different conclusions. Here are some models you might choose:\n",
"\n",
"1. **Holistic**: \"I just feel that the Rockets have about a 1/3 chance of winning it all.\"\n",
"2. **Game by Game**: \"I think the Rockets have an 75% chance of winning each game in the first round, then 70% in the next round, then 60%; from that I'll calculate their overall chance.\"\n",
@ -33,23 +33,34 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
"from statistics import mean\n",
"from random import gauss\n",
"\n",
"def simulate(diff, 𝝈=10.5, n=10000):\n",
"def simulate(diff, 𝝈=10.5, n=100000):\n",
" \"Given SRS point differential of two teams, return favored team's win probability.\"\n",
" return mean(gauss(diff, 𝝈) > 0 for game in range(n))"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 29,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"0.61204"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"simulate(7.3 - 4.3) # Raptors win probability vs Sixers"
]
@ -63,22 +74,22 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 30,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 point differential = 51% win game\n",
"1 point differential = 53% win game\n",
"2 point differential = 58% win game\n",
"0 point differential = 50% win game\n",
"1 point differential = 54% win game\n",
"2 point differential = 57% win game\n",
"3 point differential = 61% win game\n",
"4 point differential = 66% win game\n",
"4 point differential = 65% win game\n",
"5 point differential = 68% win game\n",
"6 point differential = 72% win game\n",
"7 point differential = 75% win game\n",
"8 point differential = 78% win game\n",
"8 point differential = 77% win game\n",
"9 point differential = 80% win game\n"
]
}
@ -105,7 +116,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 31,
"metadata": {},
"outputs": [],
"source": [
@ -121,40 +132,43 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We can make another table:"
"We can extend the table:"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 33,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<built-in method format of str object at 0x1035d5260>% win game = 50.0% win series\n",
"<built-in method format of str object at 0x1035d5260>% win game = 60.8% win series\n",
"<built-in method format of str object at 0x1035d5260>% win game = 71.0% win series\n",
"<built-in method format of str object at 0x1035d5260>% win game = 80.0% win series\n",
"<built-in method format of str object at 0x1035d5260>% win game = 87.4% win series\n",
"<built-in method format of str object at 0x1035d5260>% win game = 92.9% win series\n",
"<built-in method format of str object at 0x1035d5260>% win game = 96.7% win series\n",
"<built-in method format of str object at 0x1035d5260>% win game = 98.8% win series\n",
"<built-in method format of str object at 0x1035d5260>% win game = 99.7% win series\n"
"0 point differential = 50% win game = 50% win series\n",
"1 point differential = 54% win game = 58% win series\n",
"2 point differential = 58% win game = 66% win series\n",
"3 point differential = 61% win game = 73% win series\n",
"4 point differential = 65% win game = 80% win series\n",
"5 point differential = 68% win game = 85% win series\n",
"6 point differential = 72% win game = 89% win series\n",
"7 point differential = 75% win game = 93% win series\n",
"8 point differential = 78% win game = 95% win series\n",
"9 point differential = 80% win game = 97% win series\n"
]
}
],
"source": [
"for p in range(50, 95, 5):\n",
" print(format('{}% win game = {:5.1%} win series'.format(pct, win_series(p/100))))"
"for diff in range(10):\n",
" game = simulate(diff)\n",
" series = win_series(game)\n",
" print(diff, 'point differential =', pct(game), 'win game =', pct(series), 'win series')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For example, if a team has a 60% chance of winning each game, then it has an 71% chance of winning the series. This model ignores the fact that games aren't strictly independent, and ignores home court advantage. Why? Because these factors would change the final winning estimate by only a few percentage points, and I already have more uncertainty than that. \n",
"For example, a team with a 3 point differential advantage has a 61% chance of winning each game in a series, and a 73% chance of winning the series. This model ignores the fact that games aren't strictly independent, and ignores home court advantage. Why? Because these factors would change the final winning estimate by only a few percentage points, and I already have more uncertainty than that. \n",
"\n",
"What happens if some games in a series have already been played? The following function prints a table where each row tells a team's current win-loss record, each column is the game win percentage, and each entry in the table is the series win percentage."
]
@ -306,7 +320,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This puts the Rockets at 48% and 28%, which is closer to the Vegas odds of 44% and 35%. How do I reconcile this discrepancy? I guess I would say that I don't have much faith in the point differential model, because it places too much emphasis on meaningless scores: for example, in the Warriors' final game, it was to their strategic advantage to lose, and they did&mdash;by 40 points, which dropped their average differential for the entire year by 0.5 points.\n",
"This puts the Rockets at 48% and 28%, which is closer to the Vegas odds of 44% and 35%. How do I reconcile this discrepancy? I guess I would say that I don't have much faith in the point differential model, for several reasons: it counts games from the distant past, when some teams had very different lineups than they have now (due to injuries and trades); different teams have different approaches to how they handle games whose outcome is already decided; the metric puts too much emphasis on blowouts, for example, in the Warriors' final game, it was to their strategic advantage to lose, and they did it very convincingly&mdash;by 40 points, which dropped their average point differential for the entire year by 0.5 points.\n",
"\n",
"Here are my projections for the hometown Warriors:"
]
@ -339,7 +353,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"So I'm splitting the difference between 538's low estimate and Vegas's high estimate of the Warriors chances.\n",
"So I'm splitting the difference between 538's low estimate (8% win conference, 4% win title) and Vegas's high estimate (44% win conference, 35% win title).\n",
"\n",
"---"
]
@ -348,11 +362,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# 2016 NBA Playoffs\n",
"# Historical Relic: 2016 NBA Playoffs\n",
"\n",
"\n",
"An historical record of the 2016 playoffs.\n",
"\n",
"## 18 April 2016\n",
"\n",
"The Golden State Warriors have had a historic basketball season, winning more games than any other team ever has. But will they top that off by winning the championship? There are 15 other teams in contention, including one, the Spurs, that has had a historic season as the best second-best team ever. The web site fivethirtyeight, using a complicated scoring system, [gives](http://projects.fivethirtyeight.com/2016-nba-picks/) the Warriors a 44% chance of winning, with the Spurs at 28%. Basketball-reference [has](http://www.basketball-reference.com/friv/playoff_prob.cgi) the Warriors at 41% and Spurs at 32.5%, while a [betting site](http://www.oddsshark.com/nba/nba-futures) had the Warriors at 54% and Spurs at 18%. \n",