Skip to content

Instantly share code, notes, and snippets.

@deniszgonjanin
Last active December 28, 2015 20:48
Show Gist options
  • Save deniszgonjanin/7559654 to your computer and use it in GitHub Desktop.
Save deniszgonjanin/7559654 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": "NHL Team Streakiness-Copy0"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": "Are the Ottawa Senators streaky?\n=================\n\nAre certain NHL teams more streaky than others, and if so, which ones? Writing for the Ottawa Citizen, [Ian Mendes](http://twitter.com/ian_mendes) suggest that the Ottawa Senators have been the [most streaky team](http://www.ottawacitizen.com/sports/hockey/streakiest+team/9180900/story.html) in the last 2 seasons. Mendes makes a compeling argument that streaky teams such as Ottawa have performed worse than non-streaky teams such as Vancouver. Statistically speaking however, is there evidence of streaking or are we trying to find patterns where there are none? Let's find out.\n\nWe will run a very basic simulation for the period since start of 2011-12 season (about 150 games), where each team's chance of winning a game will be equal to their winning percentage for that period. So for each team we are going to flip a coin 150 times and then we will analyze the record and compare how streaky the league is compared to the real-life record.\n\nFirst, let's look at the actual streak data. Mendes defines a streak as 3 or more wins or losses in a row (OT losses count as losses), so we will stick with that definition:"
},
{
"cell_type": "code",
"collapsed": false,
"input": "# For the casual reader, skip directly to the graphs. This is just some code that crunches the data\n# The code is included here if other people wish to reproduce these results.\nfrom pandas import *\nimport csv\ntotals = pandas.read_csv('https://dl.dropboxusercontent.com/u/6526141/team_records_201114.csv', index_col=\"Team\")[[\"GP\", \"W\", \"L\", \"win %\"]]\nstreak_data = pandas.read_csv('https://dl.dropboxusercontent.com/u/6526141/streak_data_201114.csv', index_col=\"Team\")[[\"winning streaks\", \"losing streaks\", \"number of streaks\"]]\n\nprint \"\\nEach team's record since the start of 2011-2012 season:\"\n\ntotals = totals.join(streak_data)\ntotals",
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": "\nEach team's record since the start of 2011-2012 season:\n"
},
{
"html": "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>GP</th>\n <th>W</th>\n <th>L</th>\n <th>win %</th>\n <th>winning streaks</th>\n <th>losing streaks</th>\n <th>number of streaks</th>\n </tr>\n <tr>\n <th>Team</th>\n <th></th>\n <th></th>\n <th></th>\n <th></th>\n <th></th>\n <th></th>\n <th></th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>Pittsburgh Penguins</th>\n <td> 151</td>\n <td> 100</td>\n <td> 51</td>\n <td> 0.662252</td>\n <td> 12</td>\n <td> 4</td>\n <td> 16</td>\n </tr>\n <tr>\n <th>Chicago Blackhawks</th>\n <td> 151</td>\n <td> 96</td>\n <td> 56</td>\n <td> 0.635762</td>\n <td> 15</td>\n <td> 5</td>\n <td> 20</td>\n </tr>\n <tr>\n <th>St. Louis Blues</th>\n <td> 149</td>\n <td> 91</td>\n <td> 58</td>\n <td> 0.610738</td>\n <td> 18</td>\n <td> 4</td>\n <td> 22</td>\n </tr>\n <tr>\n <th>Boston Bruins</th>\n <td> 150</td>\n <td> 90</td>\n <td> 60</td>\n <td> 0.600000</td>\n <td> 12</td>\n <td> 3</td>\n <td> 15</td>\n </tr>\n <tr>\n <th>New York Rangers</th>\n <td> 150</td>\n <td> 87</td>\n <td> 63</td>\n <td> 0.580000</td>\n <td> 12</td>\n <td> 6</td>\n <td> 18</td>\n </tr>\n <tr>\n <th>Vancouver Canucks</th>\n <td> 152</td>\n <td> 88</td>\n <td> 64</td>\n <td> 0.578947</td>\n <td> 13</td>\n <td> 4</td>\n <td> 17</td>\n </tr>\n <tr>\n <th>Washington Capitals</th>\n <td> 151</td>\n <td> 81</td>\n <td> 71</td>\n <td> 0.536424</td>\n <td> 12</td>\n <td> 9</td>\n <td> 21</td>\n </tr>\n <tr>\n <th>Los Angeles Kings</th>\n <td> 151</td>\n <td> 81</td>\n <td> 70</td>\n <td> 0.536424</td>\n <td> 8</td>\n <td> 4</td>\n <td> 12</td>\n </tr>\n <tr>\n <th>San Jose Sharks</th>\n <td> 151</td>\n <td> 81</td>\n <td> 70</td>\n <td> 0.536424</td>\n <td> 11</td>\n <td> 8</td>\n <td> 19</td>\n </tr>\n <tr>\n <th>Detroit Red Wings</th>\n <td> 151</td>\n <td> 81</td>\n <td> 70</td>\n <td> 0.536424</td>\n <td> 11</td>\n <td> 9</td>\n <td> 20</td>\n </tr>\n <tr>\n <th>Philadelphia Flyers</th>\n <td> 149</td>\n <td> 77</td>\n <td> 72</td>\n <td> 0.516779</td>\n <td> 7</td>\n <td> 8</td>\n <td> 15</td>\n </tr>\n <tr>\n <th>Anaheim Ducks</th>\n <td> 153</td>\n <td> 79</td>\n <td> 74</td>\n <td> 0.516340</td>\n <td> 11</td>\n <td> 10</td>\n <td> 21</td>\n </tr>\n <tr>\n <th>Phoenix Coyotes</th>\n <td> 151</td>\n <td> 77</td>\n <td> 74</td>\n <td> 0.509934</td>\n <td> 7</td>\n <td> 7</td>\n <td> 14</td>\n </tr>\n <tr>\n <th>Dallas Stars</th>\n <td> 150</td>\n <td> 75</td>\n <td> 75</td>\n <td> 0.500000</td>\n <td> 9</td>\n <td> 8</td>\n <td> 17</td>\n </tr>\n <tr>\n <th>New Jersey Devils</th>\n <td> 150</td>\n <td> 74</td>\n <td> 76</td>\n <td> 0.493333</td>\n <td> 9</td>\n <td> 9</td>\n <td> 18</td>\n </tr>\n <tr>\n <th>Toronto Maple Leafs</th>\n <td> 150</td>\n <td> 74</td>\n <td> 77</td>\n <td> 0.493333</td>\n <td> 10</td>\n <td> 10</td>\n <td> 20</td>\n </tr>\n <tr>\n <th>Ottawa Senators</th>\n <td> 150</td>\n <td> 74</td>\n <td> 76</td>\n <td> 0.493333</td>\n <td> 13</td>\n <td> 10</td>\n <td> 23</td>\n </tr>\n <tr>\n <th>Minnesota Wild</th>\n <td> 151</td>\n <td> 74</td>\n <td> 77</td>\n <td> 0.490066</td>\n <td> 9</td>\n <td> 13</td>\n <td> 22</td>\n </tr>\n <tr>\n <th>Nashville Predators</th>\n <td> 150</td>\n <td> 73</td>\n <td> 77</td>\n <td> 0.486667</td>\n <td> 8</td>\n <td> 10</td>\n <td> 18</td>\n </tr>\n <tr>\n <th>Colorado Avalanche</th>\n <td> 149</td>\n <td> 71</td>\n <td> 78</td>\n <td> 0.476510</td>\n <td> 8</td>\n <td> 15</td>\n <td> 23</td>\n </tr>\n <tr>\n <th>Winnipeg Jets</th>\n <td> 153</td>\n <td> 72</td>\n <td> 82</td>\n <td> 0.470588</td>\n <td> 9</td>\n <td> 12</td>\n <td> 21</td>\n </tr>\n <tr>\n <th>Tampa Bay Lightning</th>\n <td> 150</td>\n <td> 70</td>\n <td> 80</td>\n <td> 0.466667</td>\n <td> 11</td>\n <td> 10</td>\n <td> 21</td>\n </tr>\n <tr>\n <th>Montreal Canadiens</th>\n <td> 151</td>\n <td> 70</td>\n <td> 82</td>\n <td> 0.463576</td>\n <td> 7</td>\n <td> 11</td>\n <td> 18</td>\n </tr>\n <tr>\n <th>New York Islanders</th>\n <td> 151</td>\n <td> 66</td>\n <td> 85</td>\n <td> 0.437086</td>\n <td> 7</td>\n <td> 14</td>\n <td> 21</td>\n </tr>\n <tr>\n <th>Buffalo Sabres</th>\n <td> 152</td>\n <td> 65</td>\n <td> 87</td>\n <td> 0.427632</td>\n <td> 10</td>\n <td> 14</td>\n <td> 24</td>\n </tr>\n <tr>\n <th>Calgary Flames</th>\n <td> 151</td>\n <td> 63</td>\n <td> 88</td>\n <td> 0.417219</td>\n <td> 5</td>\n <td> 12</td>\n <td> 17</td>\n </tr>\n <tr>\n <th>Columbus Blue Jackets</th>\n <td> 150</td>\n <td> 60</td>\n <td> 90</td>\n <td> 0.400000</td>\n <td> 9</td>\n <td> 14</td>\n <td> 23</td>\n </tr>\n <tr>\n <th>Carolina Hurricanes</th>\n <td> 151</td>\n <td> 60</td>\n <td> 91</td>\n <td> 0.397351</td>\n <td> 4</td>\n <td> 13</td>\n <td> 17</td>\n </tr>\n <tr>\n <th>Florida Panthers</th>\n <td> 151</td>\n <td> 58</td>\n <td> 93</td>\n <td> 0.384106</td>\n <td> 6</td>\n <td> 16</td>\n <td> 22</td>\n </tr>\n <tr>\n <th>Edmonton Oilers</th>\n <td> 152</td>\n <td> 56</td>\n <td> 97</td>\n <td> 0.368421</td>\n <td> 3</td>\n <td> 18</td>\n <td> 21</td>\n </tr>\n </tbody>\n</table>\n</div>",
"metadata": {},
"output_type": "pyout",
"prompt_number": 26,
"text": " GP W L win % winning streaks \\\nTeam \nPittsburgh Penguins 151 100 51 0.662252 12 \nChicago Blackhawks 151 96 56 0.635762 15 \nSt. Louis Blues 149 91 58 0.610738 18 \nBoston Bruins 150 90 60 0.600000 12 \nNew York Rangers 150 87 63 0.580000 12 \nVancouver Canucks 152 88 64 0.578947 13 \nWashington Capitals 151 81 71 0.536424 12 \nLos Angeles Kings 151 81 70 0.536424 8 \nSan Jose Sharks 151 81 70 0.536424 11 \nDetroit Red Wings 151 81 70 0.536424 11 \nPhiladelphia Flyers 149 77 72 0.516779 7 \nAnaheim Ducks 153 79 74 0.516340 11 \nPhoenix Coyotes 151 77 74 0.509934 7 \nDallas Stars 150 75 75 0.500000 9 \nNew Jersey Devils 150 74 76 0.493333 9 \nToronto Maple Leafs 150 74 77 0.493333 10 \nOttawa Senators 150 74 76 0.493333 13 \nMinnesota Wild 151 74 77 0.490066 9 \nNashville Predators 150 73 77 0.486667 8 \nColorado Avalanche 149 71 78 0.476510 8 \nWinnipeg Jets 153 72 82 0.470588 9 \nTampa Bay Lightning 150 70 80 0.466667 11 \nMontreal Canadiens 151 70 82 0.463576 7 \nNew York Islanders 151 66 85 0.437086 7 \nBuffalo Sabres 152 65 87 0.427632 10 \nCalgary Flames 151 63 88 0.417219 5 \nColumbus Blue Jackets 150 60 90 0.400000 9 \nCarolina Hurricanes 151 60 91 0.397351 4 \nFlorida Panthers 151 58 93 0.384106 6 \nEdmonton Oilers 152 56 97 0.368421 3 \n\n losing streaks number of streaks \nTeam \nPittsburgh Penguins 4 16 \nChicago Blackhawks 5 20 \nSt. Louis Blues 4 22 \nBoston Bruins 3 15 \nNew York Rangers 6 18 \nVancouver Canucks 4 17 \nWashington Capitals 9 21 \nLos Angeles Kings 4 12 \nSan Jose Sharks 8 19 \nDetroit Red Wings 9 20 \nPhiladelphia Flyers 8 15 \nAnaheim Ducks 10 21 \nPhoenix Coyotes 7 14 \nDallas Stars 8 17 \nNew Jersey Devils 9 18 \nToronto Maple Leafs 10 20 \nOttawa Senators 10 23 \nMinnesota Wild 13 22 \nNashville Predators 10 18 \nColorado Avalanche 15 23 \nWinnipeg Jets 12 21 \nTampa Bay Lightning 10 21 \nMontreal Canadiens 11 18 \nNew York Islanders 14 21 \nBuffalo Sabres 14 24 \nCalgary Flames 12 17 \nColumbus Blue Jackets 14 23 \nCarolina Hurricanes 13 17 \nFlorida Panthers 16 22 \nEdmonton Oilers 18 21 "
}
],
"prompt_number": 26
},
{
"cell_type": "markdown",
"metadata": {},
"source": "We can now run our simulation. The simulation is akin to flipping a coin for each game, where the coin is weighted on one side based on the win percentage of the team. So the Pittsburgh coin has a ~66% chance landing on a win, and ~34% chance of a loss. The table below holds the results of our simulation:"
},
{
"cell_type": "code",
"collapsed": false,
"input": "#Skip below to the graph if this code looks alien to you\nimport numpy\nsimulated_data = totals[[\"win %\", \"GP\"]]\nsimulated_data[\"outcomes\"] = \"\"\nsimulated_data[\"winning streaks\"] = 0\nsimulated_data[\"losing streaks\"] = 0\nsimulated_data[\"number of streaks\"] = 0\n\ndef generate_data(row):\n random_data = numpy.random.random_sample(row[\"GP\"])\n winning_streaks = 0\n losing_streaks = 0\n current_streak = 0\n last_result = None\n \n for number in random_data:\n if number < row[\"win %\"]:\n outcome = \"1\"\n else:\n outcome = \"0\"\n \n if last_result == outcome:\n current_streak += 1\n else:\n current_streak = 1\n \n if current_streak == 3:\n if outcome == \"1\":\n winning_streaks += 1\n else:\n losing_streaks += 1\n \n last_result = outcome\n \n row[\"outcomes\"] = row[\"outcomes\"] + outcome\n \n row[\"winning streaks\"] = winning_streaks\n row[\"losing streaks\"] = losing_streaks\n row[\"number of streaks\"] = row[\"winning streaks\"] + row[\"losing streaks\"]\n return row\n \nsimulated_data = simulated_data.apply(generate_data, axis=1)\n\nprint \"\\nSimulated winning and losing streaks:\"\nsimulated_data[[\"win %\", \"winning streaks\", \"losing streaks\", \"number of streaks\"]]",
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": "\nSimulated winning and losing streaks:\n"
},
{
"html": "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>win %</th>\n <th>winning streaks</th>\n <th>losing streaks</th>\n <th>number of streaks</th>\n </tr>\n <tr>\n <th>Team</th>\n <th></th>\n <th></th>\n <th></th>\n <th></th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>Pittsburgh Penguins</th>\n <td> 0.662252</td>\n <td> 16</td>\n <td> 5</td>\n <td> 21</td>\n </tr>\n <tr>\n <th>Chicago Blackhawks</th>\n <td> 0.635762</td>\n <td> 15</td>\n <td> 7</td>\n <td> 22</td>\n </tr>\n <tr>\n <th>St. Louis Blues</th>\n <td> 0.610738</td>\n <td> 12</td>\n <td> 8</td>\n <td> 20</td>\n </tr>\n <tr>\n <th>Boston Bruins</th>\n <td> 0.600000</td>\n <td> 16</td>\n <td> 5</td>\n <td> 21</td>\n </tr>\n <tr>\n <th>New York Rangers</th>\n <td> 0.580000</td>\n <td> 11</td>\n <td> 6</td>\n <td> 17</td>\n </tr>\n <tr>\n <th>Vancouver Canucks</th>\n <td> 0.578947</td>\n <td> 11</td>\n <td> 6</td>\n <td> 17</td>\n </tr>\n <tr>\n <th>Washington Capitals</th>\n <td> 0.536424</td>\n <td> 16</td>\n <td> 9</td>\n <td> 25</td>\n </tr>\n <tr>\n <th>Los Angeles Kings</th>\n <td> 0.536424</td>\n <td> 10</td>\n <td> 10</td>\n <td> 20</td>\n </tr>\n <tr>\n <th>San Jose Sharks</th>\n <td> 0.536424</td>\n <td> 13</td>\n <td> 10</td>\n <td> 23</td>\n </tr>\n <tr>\n <th>Detroit Red Wings</th>\n <td> 0.536424</td>\n <td> 12</td>\n <td> 8</td>\n <td> 20</td>\n </tr>\n <tr>\n <th>Philadelphia Flyers</th>\n <td> 0.516779</td>\n <td> 14</td>\n <td> 6</td>\n <td> 20</td>\n </tr>\n <tr>\n <th>Anaheim Ducks</th>\n <td> 0.516340</td>\n <td> 9</td>\n <td> 14</td>\n <td> 23</td>\n </tr>\n <tr>\n <th>Phoenix Coyotes</th>\n <td> 0.509934</td>\n <td> 8</td>\n <td> 10</td>\n <td> 18</td>\n </tr>\n <tr>\n <th>Dallas Stars</th>\n <td> 0.500000</td>\n <td> 8</td>\n <td> 6</td>\n <td> 14</td>\n </tr>\n <tr>\n <th>New Jersey Devils</th>\n <td> 0.493333</td>\n <td> 11</td>\n <td> 9</td>\n <td> 20</td>\n </tr>\n <tr>\n <th>Toronto Maple Leafs</th>\n <td> 0.493333</td>\n <td> 9</td>\n <td> 10</td>\n <td> 19</td>\n </tr>\n <tr>\n <th>Ottawa Senators</th>\n <td> 0.493333</td>\n <td> 12</td>\n <td> 9</td>\n <td> 21</td>\n </tr>\n <tr>\n <th>Minnesota Wild</th>\n <td> 0.490066</td>\n <td> 7</td>\n <td> 9</td>\n <td> 16</td>\n </tr>\n <tr>\n <th>Nashville Predators</th>\n <td> 0.486667</td>\n <td> 7</td>\n <td> 12</td>\n <td> 19</td>\n </tr>\n <tr>\n <th>Colorado Avalanche</th>\n <td> 0.476510</td>\n <td> 4</td>\n <td> 12</td>\n <td> 16</td>\n </tr>\n <tr>\n <th>Winnipeg Jets</th>\n <td> 0.470588</td>\n <td> 11</td>\n <td> 11</td>\n <td> 22</td>\n </tr>\n <tr>\n <th>Tampa Bay Lightning</th>\n <td> 0.466667</td>\n <td> 13</td>\n <td> 10</td>\n <td> 23</td>\n </tr>\n <tr>\n <th>Montreal Canadiens</th>\n <td> 0.463576</td>\n <td> 10</td>\n <td> 8</td>\n <td> 18</td>\n </tr>\n <tr>\n <th>New York Islanders</th>\n <td> 0.437086</td>\n <td> 7</td>\n <td> 12</td>\n <td> 19</td>\n </tr>\n <tr>\n <th>Buffalo Sabres</th>\n <td> 0.427632</td>\n <td> 9</td>\n <td> 14</td>\n <td> 23</td>\n </tr>\n <tr>\n <th>Calgary Flames</th>\n <td> 0.417219</td>\n <td> 6</td>\n <td> 13</td>\n <td> 19</td>\n </tr>\n <tr>\n <th>Columbus Blue Jackets</th>\n <td> 0.400000</td>\n <td> 9</td>\n <td> 11</td>\n <td> 20</td>\n </tr>\n <tr>\n <th>Carolina Hurricanes</th>\n <td> 0.397351</td>\n <td> 6</td>\n <td> 11</td>\n <td> 17</td>\n </tr>\n <tr>\n <th>Florida Panthers</th>\n <td> 0.384106</td>\n <td> 5</td>\n <td> 17</td>\n <td> 22</td>\n </tr>\n <tr>\n <th>Edmonton Oilers</th>\n <td> 0.368421</td>\n <td> 4</td>\n <td> 18</td>\n <td> 22</td>\n </tr>\n </tbody>\n</table>\n</div>",
"metadata": {},
"output_type": "pyout",
"prompt_number": 24,
"text": " win % winning streaks losing streaks \\\nTeam \nPittsburgh Penguins 0.662252 16 5 \nChicago Blackhawks 0.635762 15 7 \nSt. Louis Blues 0.610738 12 8 \nBoston Bruins 0.600000 16 5 \nNew York Rangers 0.580000 11 6 \nVancouver Canucks 0.578947 11 6 \nWashington Capitals 0.536424 16 9 \nLos Angeles Kings 0.536424 10 10 \nSan Jose Sharks 0.536424 13 10 \nDetroit Red Wings 0.536424 12 8 \nPhiladelphia Flyers 0.516779 14 6 \nAnaheim Ducks 0.516340 9 14 \nPhoenix Coyotes 0.509934 8 10 \nDallas Stars 0.500000 8 6 \nNew Jersey Devils 0.493333 11 9 \nToronto Maple Leafs 0.493333 9 10 \nOttawa Senators 0.493333 12 9 \nMinnesota Wild 0.490066 7 9 \nNashville Predators 0.486667 7 12 \nColorado Avalanche 0.476510 4 12 \nWinnipeg Jets 0.470588 11 11 \nTampa Bay Lightning 0.466667 13 10 \nMontreal Canadiens 0.463576 10 8 \nNew York Islanders 0.437086 7 12 \nBuffalo Sabres 0.427632 9 14 \nCalgary Flames 0.417219 6 13 \nColumbus Blue Jackets 0.400000 9 11 \nCarolina Hurricanes 0.397351 6 11 \nFlorida Panthers 0.384106 5 17 \nEdmonton Oilers 0.368421 4 18 \n\n number of streaks \nTeam \nPittsburgh Penguins 21 \nChicago Blackhawks 22 \nSt. Louis Blues 20 \nBoston Bruins 21 \nNew York Rangers 17 \nVancouver Canucks 17 \nWashington Capitals 25 \nLos Angeles Kings 20 \nSan Jose Sharks 23 \nDetroit Red Wings 20 \nPhiladelphia Flyers 20 \nAnaheim Ducks 23 \nPhoenix Coyotes 18 \nDallas Stars 14 \nNew Jersey Devils 20 \nToronto Maple Leafs 19 \nOttawa Senators 21 \nMinnesota Wild 16 \nNashville Predators 19 \nColorado Avalanche 16 \nWinnipeg Jets 22 \nTampa Bay Lightning 23 \nMontreal Canadiens 18 \nNew York Islanders 19 \nBuffalo Sabres 23 \nCalgary Flames 19 \nColumbus Blue Jackets 20 \nCarolina Hurricanes 17 \nFlorida Panthers 22 \nEdmonton Oilers 22 "
}
],
"prompt_number": 24
},
{
"cell_type": "markdown",
"metadata": {},
"source": "Evidence of streakiness?\n========================\n\nLet's compare some data points across the real data and the simulated data:\n\n * Average number of streaks per team:\n * Real data: 19.2\n * Simulated data: 19.9\n \n * Average number of winning streaks:\n * Real data: 9.5\n * Simulated data: 10.0\n \n * Average number of losing streaks:\n * Real data: 9.6\n * Simulated data: 9.8\n \nOur simulation gives us very similar results to the real data, so it does not look like NHL teams are any more streaky than random chance would suggest[1]. So, how do we explain our intuitive belief that some teams are streakier than others? Ian Mendes points out that streaky teams such as Ottawa find themselves in bad company with other mediocre teams. As we see from both the real and the simulated data above, all NHL teams have around 20 streaks in total. The top teams in the league have many more win streaks than loss streaks, and the bottom teams tend to have a lot more losing streaks than win streaks. \n\nI believe we percieve the middle of the pack teams as more streaky and inconsistent because their number of win streaks tends to be close to their number of losing streaks. Because these teams have won about 50% of their games over the last two years, their chances of going on a winning streak are very close to their chances of going on a losing streak, even though the total number of streaks is very similar to other NHL teams. Teams such as the Sens and the Jets, and the Capitals and the Lightning are not mediocre because they are inconsistent - their inconsistency is merely a by-product of the fact that they are mediocre. \n\n-[@deniszgonjanin](http://twitter.com/deniszgonjanin)\n\n\n\n[1] Each time this simulation is ran, the results will be different, as the simulation relies on weighted random variables. To properly assess whether the simulation is statistically significant as compared to the actual NHL results, we would need to run a Monte Carlo simulation, which is a similar process to our simulation, but ran many thousands of times. The large sample size ensures we get a more confident result."
},
{
"cell_type": "code",
"collapsed": false,
"input": "from IPython.core.display import HTML\ndef css_styling():\n styles = open(\"custom.css\", \"r\").read()\n return HTML(styles)\ncss_styling()",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<style>\n @font-face {\n font-family: \"Computer Modern\";\n src: url('http://mirrors.ctan.org/fonts/cm-unicode/fonts/otf/cmunss.otf');\n }\n div.cell{\n width:800px;\n margin-left:16% !important;\n margin-right:auto;\n }\n h1 {\n font-family: Helvetica, serif;\n }\n h4{\n margin-top:12px;\n margin-bottom: 3px;\n }\n div.text_cell_render{\n font-family: Computer Modern, \"Helvetica Neue\", Arial, Helvetica, Geneva, sans-serif;\n line-height: 145%;\n font-size: 130%;\n width:800px;\n margin-left:auto;\n margin-right:auto;\n }\n .CodeMirror{\n font-family: \"Source Code Pro\", source-code-pro,Consolas, monospace;\n }\n .prompt{\n display: None;\n }\n .text_cell_render h5 {\n font-weight: 300;\n font-size: 22pt;\n color: #4057A1;\n font-style: italic;\n margin-bottom: .5em;\n margin-top: 0.5em;\n display: block;\n }\n \n .warning{\n color: rgb( 240, 20, 20 )\n } \n</style>\n<script>\n MathJax.Hub.Config({\n TeX: {\n extensions: [\"AMSmath.js\"]\n },\n tex2jax: {\n inlineMath: [ ['$','$'], [\"\\\\(\",\"\\\\)\"] ],\n displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"] ]\n },\n displayAlign: 'center', // Change this to 'center' to center equations.\n \"HTML-CSS\": {\n styles: {'.MathJax_Display': {\"margin\": 4}}\n }\n });\n</script>",
"metadata": {},
"output_type": "pyout",
"prompt_number": 4,
"text": "<IPython.core.display.HTML at 0x1046bef10>"
}
],
"prompt_number": 4
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment