Add files via upload
This commit is contained in:
parent
cfef4208cd
commit
296168e42c
@ -54,7 +54,7 @@
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"0.61119"
|
"0.61163"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 2,
|
"execution_count": 2,
|
||||||
@ -84,7 +84,7 @@
|
|||||||
"text": [
|
"text": [
|
||||||
"0 point differential = 50% win game\n",
|
"0 point differential = 50% win game\n",
|
||||||
"1 point differential = 54% win game\n",
|
"1 point differential = 54% win game\n",
|
||||||
"2 point differential = 57% win game\n",
|
"2 point differential = 58% win game\n",
|
||||||
"3 point differential = 61% win game\n",
|
"3 point differential = 61% win game\n",
|
||||||
"4 point differential = 65% win game\n",
|
"4 point differential = 65% win game\n",
|
||||||
"5 point differential = 68% win game\n",
|
"5 point differential = 68% win game\n",
|
||||||
@ -146,16 +146,16 @@
|
|||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"0 point differential = 50% win game = 49% win series\n",
|
"0 point differential = 50% win game = 50% win series\n",
|
||||||
"1 point differential = 54% win game = 58% win series\n",
|
"1 point differential = 54% win game = 58% win series\n",
|
||||||
"2 point differential = 57% win game = 66% win series\n",
|
"2 point differential = 57% win game = 66% win series\n",
|
||||||
"3 point differential = 61% win game = 73% win series\n",
|
"3 point differential = 61% win game = 73% win series\n",
|
||||||
"4 point differential = 65% win game = 80% win series\n",
|
"4 point differential = 65% win game = 80% win series\n",
|
||||||
"5 point differential = 68% win game = 85% win series\n",
|
"5 point differential = 68% win game = 85% win series\n",
|
||||||
"6 point differential = 71% win game = 89% win series\n",
|
"6 point differential = 72% win game = 89% win series\n",
|
||||||
"7 point differential = 75% win game = 93% win series\n",
|
"7 point differential = 75% win game = 93% win series\n",
|
||||||
"8 point differential = 78% win game = 95% win series\n",
|
"8 point differential = 78% win game = 95% win series\n",
|
||||||
"9 point differential = 80% win game = 97% win series\n"
|
"9 point differential = 81% win game = 97% win series\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -330,7 +330,7 @@
|
|||||||
"Rockets vs Wolves 89%; through here: 89%\n",
|
"Rockets vs Wolves 89%; through here: 89%\n",
|
||||||
"Rockets vs Jazz 78%; through here: 69%\n",
|
"Rockets vs Jazz 78%; through here: 69%\n",
|
||||||
"Rockets vs Warriors 69%; through here: 48%\n",
|
"Rockets vs Warriors 69%; through here: 48%\n",
|
||||||
"Rockets vs Raptors 57%; through here: 27%\n"
|
"Rockets vs Raptors 58%; through here: 28%\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -351,9 +351,9 @@
|
|||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"Warriors vs Spurs 73%; through here: 73%\n",
|
"Warriors vs Spurs 72%; through here: 72%\n",
|
||||||
"Warriors vs Blazers 74%; through here: 54%\n",
|
"Warriors vs Blazers 74%; through here: 54%\n",
|
||||||
"Warriors vs Rockets 31%; through here: 17%\n",
|
"Warriors vs Rockets 31%; through here: 16%\n",
|
||||||
"Warriors vs Raptors 38%; through here: 6%\n"
|
"Warriors vs Raptors 38%; through here: 6%\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -374,13 +374,27 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"# Series Length\n",
|
"# Series Length\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Given a team's game win percentage, how many games should we expect a series to run? That is, with a game win percentage of 60%, how likely is it to sweep all 4 games? To go to 7 games? Here's a chart:"
|
"Given a team's game win percentage, how many games should we expect a series to run? That is, with a game win percentage of 60%, how likely is it to sweep all 4 games? To go to 7 games? Here's a chart of the probability of each possible series outcome, based on the win percentage of the first team:"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 12,
|
"execution_count": 12,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import collections\n",
|
||||||
|
"\n",
|
||||||
|
"class MCounter(collections.Counter):\n",
|
||||||
|
" \"A multipliable Counter: you can say `2 * MCounter(stuff)`.\"\n",
|
||||||
|
" def __mul__(self, p): return MCounter({k: p * self[k] for k in self})\n",
|
||||||
|
" __rmul__ = __mul__"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 13,
|
||||||
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
@ -401,11 +415,9 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"from collections import Counter\n",
|
"def series_results(p, W=0, L=0) -> MCounter:\n",
|
||||||
"\n",
|
|
||||||
"def series_results(p, W=0, L=0):\n",
|
|
||||||
" \"\"\"Return {(win, loss): probability} for all possible outcomes of the series.\"\"\"\n",
|
" \"\"\"Return {(win, loss): probability} for all possible outcomes of the series.\"\"\"\n",
|
||||||
" return MCounter([(W, L)] if W == 4 or L == 4 else\n",
|
" return MCounter([(W, L)] if W == 4 or L == 4 else\n",
|
||||||
" (p * series_results(p, W + 1, L) + \n",
|
" (p * series_results(p, W + 1, L) + \n",
|
||||||
" (1 - p) * series_results(p, W, L + 1)))\n",
|
" (1 - p) * series_results(p, W, L + 1)))\n",
|
||||||
" \n",
|
" \n",
|
||||||
@ -417,12 +429,7 @@
|
|||||||
" for (W, L) in outcomes:\n",
|
" for (W, L) in outcomes:\n",
|
||||||
" results = [series_results(p)[W, L] for p in pcts]\n",
|
" results = [series_results(p)[W, L] for p in pcts]\n",
|
||||||
" print('{}-{} | {}'.format(W, L, ' '.join(map(pct, results))))\n",
|
" print('{}-{} | {}'.format(W, L, ' '.join(map(pct, results))))\n",
|
||||||
" \n",
|
"\n",
|
||||||
"class MCounter(Counter):\n",
|
|
||||||
" \"A multipliable Counter.\"\n",
|
|
||||||
" def __mul__(self, p): return MCounter({k: p * self[k] for k in self})\n",
|
|
||||||
" __rmul__ = __mul__\n",
|
|
||||||
" \n",
|
|
||||||
"series_results_table()"
|
"series_results_table()"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -430,9 +437,9 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"So we see that our 60% team has a 13% chance of sweeping, and 13+21+21 = 55% chance of winning in 6 games or less.\n",
|
"So we see that our 60% team has a 13% chance of sweeping (4-0), and 13+21+21 = 55% chance of winning in 6 games or less.\n",
|
||||||
"\n",
|
"\n",
|
||||||
"**Note:** I think `Counter` should support multiplication. If `C` is a `Counter`, then shouldn't `C + C` be the same as `2 * C`?"
|
"**Note:** I had to define `MCounter` because `collectionsCounter` does not support multiplication. I think it should: if `C` is a `Counter`, then shouldn't `C + C` be the same as `2 * C`?"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -461,7 +468,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 13,
|
"execution_count": 14,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"scrolled": true
|
"scrolled": true
|
||||||
},
|
},
|
||||||
@ -487,7 +494,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 14,
|
"execution_count": 15,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
@ -511,7 +518,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 15,
|
"execution_count": 16,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
@ -555,7 +562,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 16,
|
"execution_count": 17,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
@ -586,7 +593,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 17,
|
"execution_count": 18,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
@ -610,7 +617,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 18,
|
"execution_count": 19,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
@ -653,7 +660,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 19,
|
"execution_count": 20,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
@ -677,7 +684,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 20,
|
"execution_count": 21,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
@ -701,7 +708,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 21,
|
"execution_count": 22,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
@ -725,7 +732,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 22,
|
"execution_count": 23,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
@ -769,7 +776,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 23,
|
"execution_count": 24,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
@ -804,7 +811,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 24,
|
"execution_count": 25,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
@ -828,7 +835,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 25,
|
"execution_count": 26,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
@ -852,7 +859,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 26,
|
"execution_count": 27,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
@ -889,7 +896,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 27,
|
"execution_count": 28,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
@ -936,16 +943,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 28,
|
"execution_count": 29,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"0.967480202675441"
|
"0.966301733"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 28,
|
"execution_count": 29,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user