Skip to main content

More March Madness Monte Carlo style

You can download this post as a Juypter notebook here

MMMC the 2015 update

See the original blog post for details and history. Here's the short story: in my Statistical and Thermal Physics class, we want to use Monte Carlo simulations to generate brackets for March Madness. There are at least two obvious ways to go about this:

  1. Make some function that tells us the chance that team A beats team B, then flip coins for each matchup. That gets you one bracket. Repeat 100,000 times, collect statistics. This is the way Nate Silver's 538.com handles simulations for basketball, elections, etc, and I should probably implement it (note to self/motivated students: it's as easy as just generating 100,000 new brackets at a given temperature).

  2. Generate one bracket, then do a Monte-Carlo walk through bracket space. This is tougher. We have to figure out how to make a move in bracket space, which is part of the fun of Monte Carlo simulations in general. To see how this is done, check out the code in Bracket.swap and Brackets.simulate.

As you can tell, we take option 2 above. I've made things a bit nicer from a user standpoint this year; here's a walkthrough. First, load up our standard IPython setup

In [1]:
from __future__ import division
%matplotlib inline
import seaborn as sns
sns.set_style('darkgrid')
import numpy as np
from matplotlib import pyplot as plt
from IPython.display import HTML

The basics

make me a single bracket at a given temperature

In [2]:
import MarchMadnessMonteCarlo as MMMC
teams = MMMC.teams['south']
b = MMMC.Bracket(teams=teams,T=0.5)
print b
Duke (1)                                                     
Robert Morris (16)        Duk (1)                            
San Diego St. (8)                                            
St. John's (9)            San (8)  Duk (1)                   
Utah (5)                                                     
Stephen F. Austin (12)    Ste (12)                           
Georgetown (4)                                               
Eastern Washington (13)   Geo (4)  Ste (12) Ste (12)         
SMU (6)                   UCL (11) UCL (11) UCL (11) Ste (12)
UCLA (11)                                                    
Iowa St. (3)              Iow (3)                            
UAB (14)                                                     
Iowa (7)                  Iow (7)  Iow (7)                   
Davidson (10)                                                
Gonzaga (2)               Gon (2)                            
North Dakota St. (15)                                        
Total bracket energy: -17.4533174222

Now, instead of asking for all of the teams in the South, make up a set of Final Four teams, and run 1000 simulations. Show some statistics

In [3]:
sr = MMMC.simulate(1000,['Kentucky','Wisconsin','Villanova','Duke'],0.5)
MMMC.showstats(sr,newfig=True)
Lowest energy bracket
Kentucky (1)                               
Wisconsin (1)             Ken (1)          
Villanova (1)             Vil (1)  Ken (1) 
Duke (1)                                   
Total bracket energy: -3.05919025906

Most common bracket (159)
Kentucky (1)                               
Wisconsin (1)             Ken (1)          
Villanova (1)             Duk (1)  Ken (1) 
Duke (1)                                   
Total bracket energy: -3.04122415391

As you can see, we fully sample bracket space pretty quickly (look at the graph in the top right, with the unique brackets shown).

What should our temperature be?

If we had chosen option 1 at the top, we'd just flip coins with a given probability of winning. Here (and this may be a questionable decision), we need to set an overall temperature for our simulation. Intuitively, the higher the temperature, the closer we come to a random outcome. The lower the temperature, the closer we come to a "best seed always wins" bracket. If we're going to make sense of temperature, we should pick a reasonable energy function.

We can use KenPom's log5 defined as

def log5_energy_game(winner, loser):
    A,B = strength[winner],strength[loser]
    # see http://207.56.97.150/articles/playoff2002.htm
    win_pct = (A-A*B)/(A+B-2*A*B)
    return -win_pct

Conveniently, that's coded up for you in MarchMadnessMonteCarlo.examples.

Later on, we could make a fancy energy function with, e.g., a weighted average of KenPom, Jeff Sagarin, and the NCAA rankings.

In [4]:
import MarchMadnessMonteCarlo.examples
MMMC.set_energy_function(MarchMadnessMonteCarlo.examples.log5_energy_game)

Now, what should our actual temperature be? Historically, we know that an 8 seed vs. a 9 seed should essentially be a tossup. So, as a proxy here, we could just look at the chance of an 8 seed winning over a range of temperatures, and pick the point where it's pretty close to 0.5.

In [5]:
def winpct8(team8,team9,T,numtrials=10000):
    results = [MMMC.playgame(team8,team9,T)[0] == team8 for i in range(numtrials)]
    return np.average(results)
def plotwins(team8,team9,numtrials=10000):
    Ts = np.linspace(0,3,100)
    pct = [winpct8(team8,team9,T,numtrials) for T in Ts]
    plt.plot(Ts,pct,label='{t1} vs. {t2}'.format(t1=team8,t2=team9))
    plt.xlabel('T')
    plt.ylabel('winpct')

We'll look at it for all four of the 8 vs. 9 matchups

In [6]:
plotwins('Cincinnati','Purdue')
plotwins('Oregon','Oklahoma St.')
plotwins('North Carolina St.','LSU')
plotwins('San Diego St.',"St. John's")
plt.legend()
Out[6]:
<matplotlib.legend.Legend at 0x7fc7e94c7650>

A couple of things jump out. First, the green line: KenPom has Oregon ranked below Oklahoma State, so the curve approaches 50% from below instead of from above.

Second, just eyeballing that, it looks like we could make a legitimate argument for almost anything between T=1.0 and 2.0.

What does that do to "clear" matchups? Well, Kentucky is a big favorite over Kansas with this model:

In [7]:
MarchMadnessMonteCarlo.examples.log5_energy_game('Kentucky','Kansas')
Out[7]:
-0.8176307825952608
In [8]:
plotwins('Kentucky','Kansas')

If I pick T=1.5, I get Kentucky, the favorite, winning 60% of the time. You can feel free to choose a "saner" temperature, but I'm rooting for KU here!

Running some brackets!

So what does a bracket happen to look like? Well, in the original blog post, I mentioned that we came up with two different ways to run brackets. It can take a while to run a bracket, so a fast way (implemented as runbracket2) is to run separate brackets for each of the individual regions, then take the winner from each region's most common bracket to form a Final Four. Below, we do just that, running 10,000 trials for each of the regions, and 1000 trials for the Final Four.

In [9]:
results = MMMC.runbracket2(ntrials1=10000,ntrials2=1000,T=1.5)
YOUR LOWEST ENERGY BRACKETS
LOWEST ENERGY BRACKET FOR REGION midwest
Kentucky (1)                                                 
Hampton (16)              Ken (1)                            
Cincinnati (8)                                               
Purdue (9)                Cin (8)  Ken (1)                   
West Virginia (5)                                            
Buffalo (12)              Wes (5)                            
Maryland (4)                                                 
Valparaiso (13)           Mar (4)  Wes (5)  Ken (1)          
Butler (6)                Tex (11) Not (3)  Not (3)  Ken (1) 
Texas (11)                                                   
Notre Dame (3)            Not (3)                            
Northeastern (14)                                            
Wichita St. (7)           Wic (7)  Kan (2)                   
Indiana (10)                                                 
Kansas (2)                Kan (2)                            
New Mexico St. (15)                                          
Total bracket energy: -10.5524230049


LOWEST ENERGY BRACKET FOR REGION west
Wisconsin (1)                                                
Coastal Carolina (16)     Wis (1)                            
Oregon (8)                                                   
Oklahoma St. (9)          Okl (9)  Wis (1)                   
Arkansas (5)                                                 
Wofford (12)              Ark (5)                            
North Carolina (4)                                           
Harvard (13)              Nor (4)  Nor (4)  Wis (1)          
Xavier (6)                Xav (6)  Bay (3)  Ari (2)  Ari (2) 
Mississippi (11)                                             
Baylor (3)                Bay (3)                            
Georgia St. (14)                                             
VCU (7)                   Ohi (10) Ari (2)                   
Ohio St. (10)                                                
Arizona (2)               Ari (2)                            
Texas Southern (15)                                          
Total bracket energy: -10.8592988759


LOWEST ENERGY BRACKET FOR REGION south
Duke (1)                                                     
Robert Morris (16)        Duk (1)                            
San Diego St. (8)                                            
St. John's (9)            San (8)  Duk (1)                   
Utah (5)                                                     
Stephen F. Austin (12)    Uta (5)                            
Georgetown (4)                                               
Eastern Washington (13)   Geo (4)  Uta (5)  Duk (1)          
SMU (6)                   SMU (6)  Iow (3)  Gon (2)  Gon (2) 
UCLA (11)                                                    
Iowa St. (3)              Iow (3)                            
UAB (14)                                                     
Iowa (7)                  Iow (7)  Gon (2)                   
Davidson (10)                                                
Gonzaga (2)               Gon (2)                            
North Dakota St. (15)                                        
Total bracket energy: -10.5015086048


LOWEST ENERGY BRACKET FOR REGION east
Villanova (1)                                                
Lafayette (16)            Vil (1)                            
North Carolina St. (8)                                       
LSU (9)                   Nor (8)  Vil (1)                   
Northern Iowa (5)                                            
Wyoming (12)              Nor (5)                            
Louisville (4)                                               
UC Irvine (13)            Lou (4)  Nor (5)  Vil (1)          
Providence (6)            Pro (6)  Okl (3)  Vir (2)  Vir (2) 
Dayton (11)                                                  
Oklahoma (3)              Okl (3)                            
Albany (14)                                                  
Michigan St. (7)          Mic (7)  Vir (2)                   
Georgia (10)                                                 
Virginia (2)              Vir (2)                            
Belmont (15)                                                 
Total bracket energy: -10.8839299775


LOWEST ENERGY BRACKET FOR FINAL FOUR
Kentucky (1)                               
Wisconsin (1)             Ken (1)          
Utah (5)                  Vir (2)  Ken (1) 
Virginia (2)                               
Total bracket energy: -1.95692907302

YOUR MOST COMMON BRACKETS
MOST COMMON BRACKET FOR REGION midwest
Kentucky (1)                                                 
Hampton (16)              Ken (1)                            
Cincinnati (8)                                               
Purdue (9)                Pur (9)  Ken (1)                   
West Virginia (5)                                            
Buffalo (12)              Wes (5)                            
Maryland (4)                                                 
Valparaiso (13)           Mar (4)  Mar (4)  Ken (1)          
Butler (6)                Tex (11) Not (3)  Kan (2)  Ken (1) 
Texas (11)                                                   
Notre Dame (3)            Not (3)                            
Northeastern (14)                                            
Wichita St. (7)           Wic (7)  Kan (2)                   
Indiana (10)                                                 
Kansas (2)                Kan (2)                            
New Mexico St. (15)                                          
Total bracket energy: -10.3577160931

number of times this bracket happened: 11


MOST COMMON BRACKET FOR REGION west
Wisconsin (1)                                                
Coastal Carolina (16)     Wis (1)                            
Oregon (8)                                                   
Oklahoma St. (9)          Ore (8)  Wis (1)                   
Arkansas (5)                                                 
Wofford (12)              Ark (5)                            
North Carolina (4)                                           
Harvard (13)              Nor (4)  Nor (4)  Wis (1)          
Xavier (6)                Mis (11) Mis (11) Ohi (10) Wis (1) 
Mississippi (11)                                             
Baylor (3)                Geo (14)                           
Georgia St. (14)                                             
VCU (7)                   Ohi (10) Ohi (10)                  
Ohio St. (10)                                                
Arizona (2)               Tex (15)                           
Texas Southern (15)                                          
Total bracket energy: -9.30614882152

number of times this bracket happened: 13


MOST COMMON BRACKET FOR REGION south
Duke (1)                                                     
Robert Morris (16)        Duk (1)                            
San Diego St. (8)                                            
St. John's (9)            St. (9)  Duk (1)                   
Utah (5)                                                     
Stephen F. Austin (12)    Uta (5)                            
Georgetown (4)                                               
Eastern Washington (13)   Geo (4)  Uta (5)  Uta (5)          
SMU (6)                   UCL (11) UCL (11) Gon (2)  Uta (5) 
UCLA (11)                                                    
Iowa St. (3)              Iow (3)                            
UAB (14)                                                     
Iowa (7)                  Dav (10) Gon (2)                   
Davidson (10)                                                
Gonzaga (2)               Gon (2)                            
North Dakota St. (15)                                        
Total bracket energy: -9.78926932204

number of times this bracket happened: 9


MOST COMMON BRACKET FOR REGION east
Villanova (1)                                                
Lafayette (16)            Vil (1)                            
North Carolina St. (8)                                       
LSU (9)                   LSU (9)  Vil (1)                   
Northern Iowa (5)                                            
Wyoming (12)              Nor (5)                            
Louisville (4)                                               
UC Irvine (13)            Lou (4)  Lou (4)  Vil (1)          
Providence (6)            Day (11) Okl (3)  Vir (2)  Vir (2) 
Dayton (11)                                                  
Oklahoma (3)              Okl (3)                            
Albany (14)                                                  
Michigan St. (7)          Geo (10) Vir (2)                   
Georgia (10)                                                 
Virginia (2)              Vir (2)                            
Belmont (15)                                                 
Total bracket energy: -10.5204279257

number of times this bracket happened: 11


MOST COMMON BRACKET FOR FINAL FOUR
Kentucky (1)                               
Wisconsin (1)             Ken (1)          
Utah (5)                  Uta (5)  Ken (1) 
Virginia (2)                               
Total bracket energy: -1.78538460124

number of times this bracket happened: 176

So, not looking so hot for my Kansas, but the code is working.

Let's visualize the results, then make a table of results, as per 538.

In [10]:
# Basic visualization
for region in 'midwest west east south'.split():
    MMMC.showstats(results[region],description=region,newfig=True)

Here you can see the classic reason to do Monte Carlo samping in the first place: we're absolutely nowhere near fully sampling bracket space. You can tell this from each of the "Unique brackets over the trajectory" plots, none of which have leveled out.

Further, you can see that the strength distribution in each of the regions is pretty different. Check out the energy distribution histograms for visual proof.

Nice tables

And here's our set of tabulated results. Note that things look a little funny for the Final Four: runbracket2 runs the final four separate from the rest of the tourney. So, only four teams are allowed to have Championship and Win percentages above zero (the final four percentages are taken from the first chunk of the tourney).

In [11]:
h = HTML(MMMC.maketable(results))
h
Out[11]:
Team Region Rank 2nd Round 3rd Round Sweet 16 Elite 8 Final 4 Championship Win
Kentucky midwest 1 100.0 65.74 49.18 36.16 25.29 55.3 34.5
Wisconsin west 1 100.0 63.38 44.28 30.04 19.44 44.7 24.2
Virginia east 2 100.0 64.6 41.15 27.68 17.86 51.3 22.4
Utah south 5 100.0 58.29 35.86 20.96 12.19 48.7 18.9
Arizona west 2 100.0 62.35 42.23 28.64 18.74 0.0 0.0
Villanova east 1 100.0 65.73 44.05 29.84 18.61 0.0 0.0
Duke south 1 100.0 66.03 41.64 25.2 15.05 0.0 0.0
Gonzaga south 2 100.0 61.67 37.12 23.51 14.22 0.0 0.0
Kansas midwest 2 100.0 58.6 33.71 19.16 10.31 0.0 0.0
Oklahoma east 3 100.0 60.74 34.96 18.34 10.01 0.0 0.0
Northern Iowa east 5 100.0 65.23 37.58 19.72 9.97 0.0 0.0
Notre Dame midwest 3 100.0 57.37 32.47 18.57 9.65 0.0 0.0
Iowa St. south 3 100.0 57.01 33.22 17.32 9.07 0.0 0.0
Baylor west 3 100.0 56.3 33.23 16.77 8.79 0.0 0.0
North Carolina west 4 100.0 61.15 35.63 17.73 8.7 0.0 0.0
SMU south 6 100.0 53.2 28.16 14.61 7.62 0.0 0.0
Wichita St. midwest 7 100.0 51.59 28.31 15.41 7.54 0.0 0.0
Georgetown south 4 100.0 60.99 28.74 15.08 7.37 0.0 0.0
Michigan St. east 7 100.0 55.17 25.73 14.43 7.17 0.0 0.0
Iowa south 7 100.0 51.15 25.99 13.76 6.63 0.0 0.0
Louisville east 4 100.0 56.62 29.3 14.05 6.58 0.0 0.0
West Virginia midwest 5 100.0 55.77 31.54 13.3 6.47 0.0 0.0
Providence east 6 100.0 53.03 27.3 12.58 6.19 0.0 0.0
Butler midwest 6 100.0 53.61 27.03 13.43 6.05 0.0 0.0
Texas midwest 11 100.0 46.39 23.9 12.46 5.99 0.0 0.0
Xavier west 6 100.0 50.71 25.68 12.46 5.95 0.0 0.0
Ohio St. west 10 100.0 51.62 22.26 11.19 5.29 0.0 0.0
Arkansas west 5 100.0 57.67 28.22 11.83 5.14 0.0 0.0
Maryland midwest 4 100.0 55.25 25.84 11.73 5.14 0.0 0.0
VCU west 7 100.0 48.38 21.78 11.24 5.06 0.0 0.0
Oklahoma St. west 9 100.0 50.19 21.58 11.31 4.84 0.0 0.0
San Diego St. south 8 100.0 47.92 23.04 10.71 4.81 0.0 0.0
Oregon west 8 100.0 49.81 20.61 10.42 4.73 0.0 0.0
Cincinnati midwest 8 100.0 49.74 19.41 9.93 4.72 0.0 0.0
Davidson south 10 100.0 48.85 23.46 10.7 4.54 0.0 0.0
LSU east 9 100.0 53.31 24.25 11.58 4.53 0.0 0.0
North Carolina St. east 8 100.0 46.69 21.93 10.18 4.35 0.0 0.0
Stephen F. Austin south 12 100.0 41.71 21.31 9.08 4.3 0.0 0.0
UCLA south 11 100.0 46.8 21.71 9.51 4.22 0.0 0.0
St. John's south 9 100.0 52.08 22.83 9.84 4.17 0.0 0.0
Purdue midwest 9 100.0 50.26 19.41 8.86 3.76 0.0 0.0
Buffalo midwest 12 100.0 44.23 23.13 8.76 3.55 0.0 0.0
Georgia east 10 100.0 44.83 19.41 8.76 3.53 0.0 0.0
Dayton east 11 100.0 46.97 22.59 8.55 3.52 0.0 0.0
Mississippi west 11 100.0 49.29 21.45 9.01 3.51 0.0 0.0
Indiana midwest 10 100.0 48.41 22.29 8.57 3.14 0.0 0.0
Valparaiso midwest 13 100.0 44.75 19.49 7.86 3.1 0.0 0.0
Georgia St. west 14 100.0 43.7 19.64 6.96 2.67 0.0 0.0
Harvard west 13 100.0 38.85 18.65 6.98 2.36 0.0 0.0
Wofford west 12 100.0 42.33 17.5 6.84 2.33 0.0 0.0
New Mexico St. midwest 15 100.0 41.4 15.69 6.3 2.26 0.0 0.0
UC Irvine east 13 100.0 43.38 19.57 6.64 2.17 0.0 0.0
Northeastern midwest 14 100.0 42.63 16.6 6.1 2.17 0.0 0.0
UAB south 14 100.0 42.99 16.91 6.09 2.02 0.0 0.0
Wyoming east 12 100.0 34.77 13.55 5.06 1.8 0.0 0.0
Albany east 14 100.0 39.26 15.15 4.86 1.59 0.0 0.0
Eastern Washington south 13 100.0 39.01 14.09 5.06 1.42 0.0 0.0
Coastal Carolina west 16 100.0 36.62 13.53 4.85 1.42 0.0 0.0
North Dakota St. south 15 100.0 38.33 13.43 4.5 1.35 0.0 0.0
Belmont east 15 100.0 35.4 13.71 4.8 1.28 0.0 0.0
Texas Southern west 15 100.0 37.65 13.73 3.73 1.03 0.0 0.0
Robert Morris south 16 100.0 33.97 12.49 4.07 1.02 0.0 0.0
Hampton midwest 16 100.0 34.26 12.0 3.4 0.86 0.0 0.0
Lafayette east 16 100.0 34.27 9.77 2.93 0.84 0.0 0.0

Given those concerns, let's just run runbracket1 and look at the results

In [12]:
results = MMMC.runbracket1(ntrials=10000,T=1.5)
Lowest energy bracket
Kentucky (1)                                                                   
Hampton (16)              Ken (1)                                              
Cincinnati (8)                                                                 
Purdue (9)                Cin (8)  Ken (1)                                     
West Virginia (5)                                                              
Buffalo (12)              Wes (5)                                              
Maryland (4)                                                                   
Valparaiso (13)           Mar (4)  Wes (5)  Ken (1)                            
Butler (6)                                                                     
Texas (11)                Tex (11)                                             
Notre Dame (3)                                                                 
Northeastern (14)         Not (3)  Not (3)                                     
Wichita St. (7)                                                                
Indiana (10)              Wic (7)                                              
Kansas (2)                                                                     
New Mexico St. (15)       Kan (2)  Kan (2)  Not (3)  Ken (1)                   
Duke (1)                                                                       
Robert Morris (16)        Duk (1)                                              
San Diego St. (8)                                                              
St. John's (9)            San (8)  Duk (1)                                     
Utah (5)                                                                       
Stephen F. Austin (12)    Uta (5)                                              
Georgetown (4)                                                                 
Eastern Washington (13)   Geo (4)  Uta (5)  Duk (1)                            
SMU (6)                                                                        
UCLA (11)                 SMU (6)                                              
Iowa St. (3)                                                                   
UAB (14)                  Iow (3)  Iow (3)                                     
Iowa (7)                                                                       
Davidson (10)             Iow (7)                                              
Gonzaga (2)                                                                    
North Dakota St. (15)     Gon (2)  Gon (2)  Gon (2)  Gon (2)  Ken (1)          
Wisconsin (1)             Wis (1)  Wis (1)  Wis (1)  Ari (2)  Ari (2)  Ken (1) 
Coastal Carolina (16)                                                          
Oregon (8)                Okl (9)                                              
Oklahoma St. (9)                                                               
Arkansas (5)              Ark (5)  Nor (4)                                     
Wofford (12)                                                                   
North Carolina (4)        Nor (4)                                              
Harvard (13)                                                                   
Xavier (6)                Xav (6)  Bay (3)  Ari (2)                            
Mississippi (11)                                                               
Baylor (3)                Bay (3)                                              
Georgia St. (14)                                                               
VCU (7)                   Ohi (10) Ari (2)                                     
Ohio St. (10)                                                                  
Arizona (2)               Ari (2)                                              
Texas Southern (15)                                                            
Villanova (1)             Vil (1)  Vil (1)  Vil (1)  Vir (2)                   
Lafayette (16)                                                                 
North Carolina St. (8)    Nor (8)                                              
LSU (9)                                                                        
Northern Iowa (5)         Nor (5)  Nor (5)                                     
Wyoming (12)                                                                   
Louisville (4)            Lou (4)                                              
UC Irvine (13)                                                                 
Providence (6)            Pro (6)  Okl (3)  Vir (2)                            
Dayton (11)                                                                    
Oklahoma (3)              Okl (3)                                              
Albany (14)                                                                    
Michigan St. (7)          Mic (7)  Vir (2)                                     
Georgia (10)                                                                   
Virginia (2)              Vir (2)                                              
Belmont (15)                                                                   
Total bracket energy: -44.697443432

Most common bracket (7)
Kentucky (1)                                                                   
Hampton (16)              Ham (16)                                             
Cincinnati (8)                                                                 
Purdue (9)                Cin (8)  Cin (8)                                     
West Virginia (5)                                                              
Buffalo (12)              Wes (5)                                              
Maryland (4)                                                                   
Valparaiso (13)           Mar (4)  Wes (5)  Cin (8)                            
Butler (6)                                                                     
Texas (11)                But (6)                                              
Notre Dame (3)                                                                 
Northeastern (14)         Nor (14) But (6)                                     
Wichita St. (7)                                                                
Indiana (10)              Wic (7)                                              
Kansas (2)                                                                     
New Mexico St. (15)       Kan (2)  Kan (2)  But (6)  But (6)                   
Duke (1)                                                                       
Robert Morris (16)        Rob (16)                                             
San Diego St. (8)                                                              
St. John's (9)            San (8)  San (8)                                     
Utah (5)                                                                       
Stephen F. Austin (12)    Uta (5)                                              
Georgetown (4)                                                                 
Eastern Washington (13)   Geo (4)  Geo (4)  Geo (4)                            
SMU (6)                                                                        
UCLA (11)                 SMU (6)                                              
Iowa St. (3)                                                                   
UAB (14)                  Iow (3)  Iow (3)                                     
Iowa (7)                                                                       
Davidson (10)             Iow (7)                                              
Gonzaga (2)                                                                    
North Dakota St. (15)     Gon (2)  Gon (2)  Gon (2)  Gon (2)  Gon (2)          
Wisconsin (1)             Wis (1)  Ore (8)  Ore (8)  Ari (2)  Ari (2)  Ari (2) 
Coastal Carolina (16)                                                          
Oregon (8)                Ore (8)                                              
Oklahoma St. (9)                                                               
Arkansas (5)              Ark (5)  Nor (4)                                     
Wofford (12)                                                                   
North Carolina (4)        Nor (4)                                              
Harvard (13)                                                                   
Xavier (6)                Xav (6)  Xav (6)  Ari (2)                            
Mississippi (11)                                                               
Baylor (3)                Bay (3)                                              
Georgia St. (14)                                                               
VCU (7)                   Ohi (10) Ari (2)                                     
Ohio St. (10)                                                                  
Arizona (2)               Ari (2)                                              
Texas Southern (15)                                                            
Villanova (1)             Laf (16) Nor (8)  Nor (5)  Mic (7)                   
Lafayette (16)                                                                 
North Carolina St. (8)    Nor (8)                                              
LSU (9)                                                                        
Northern Iowa (5)         Nor (5)  Nor (5)                                     
Wyoming (12)                                                                   
Louisville (4)            UC  (13)                                             
UC Irvine (13)                                                                 
Providence (6)            Pro (6)  Pro (6)  Mic (7)                            
Dayton (11)                                                                    
Oklahoma (3)              Okl (3)                                              
Albany (14)                                                                    
Michigan St. (7)          Mic (7)  Mic (7)                                     
Georgia (10)                                                                   
Virginia (2)              Bel (15)                                             
Belmont (15)                                                                   
Total bracket energy: -38.100050778

In [13]:
h = HTML(MMMC.maketable(results))
h
Out[13]:
Team Region Rank 2nd Round 3rd Round Sweet 16 Elite 8 Final 4 Championship Win
Kentucky midwest 1 100.0 58.69 44.77 32.58 23.98 16.41 10.87
Villanova east 1 100.0 65.53 45.71 32.0 20.87 13.77 8.67
Arizona west 2 100.0 62.57 44.59 33.54 20.75 13.11 8.03
Wisconsin west 1 100.0 67.67 43.02 27.42 18.12 11.35 7.15
Virginia east 2 100.0 63.76 43.67 30.86 19.05 11.08 6.59
Gonzaga south 2 100.0 57.98 39.95 25.46 15.02 9.09 4.78
Utah south 5 100.0 57.92 34.4 21.04 13.19 6.8 3.66
Duke south 1 100.0 60.1 35.45 18.48 11.41 6.73 3.49
Notre Dame midwest 3 100.0 61.12 33.93 19.4 11.17 5.57 2.8
Oklahoma east 3 100.0 62.0 37.74 17.64 10.01 5.26 2.64
Kansas midwest 2 100.0 66.57 35.81 19.02 9.97 5.45 2.59
Northern Iowa east 5 100.0 62.27 35.11 18.67 10.05 4.82 2.38
Iowa St. south 3 100.0 60.06 36.95 20.04 11.12 5.24 2.36
Wichita St. midwest 7 100.0 56.94 31.91 19.06 8.76 4.18 2.17
North Carolina west 4 100.0 58.35 32.3 18.51 9.54 4.23 1.82
SMU south 6 100.0 55.35 29.26 16.91 8.61 3.79 1.61
Baylor west 3 100.0 56.63 29.51 11.82 7.12 3.63 1.56
Georgetown south 4 100.0 56.75 29.58 15.75 7.23 3.24 1.42
Texas midwest 11 100.0 58.28 27.89 14.8 6.87 3.3 1.39
Michigan St. east 7 100.0 59.67 27.43 14.51 6.41 2.98 1.29
Ohio St. west 10 100.0 50.4 23.8 12.61 6.46 3.19 1.27
West Virginia midwest 5 100.0 58.66 33.41 13.82 6.62 2.97 1.17
Arkansas west 5 100.0 57.66 31.16 12.71 5.34 2.38 1.16
Louisville east 4 100.0 55.49 31.49 15.28 7.18 3.1 1.14
Iowa south 7 100.0 55.68 25.06 9.92 5.49 2.67 1.13
Butler midwest 6 100.0 41.72 24.06 11.13 6.36 2.77 1.12
Xavier west 6 100.0 56.43 31.36 14.27 6.71 2.44 1.12
San Diego St. south 8 100.0 52.15 29.17 12.83 6.64 2.88 1.03
Cincinnati midwest 8 100.0 50.58 20.36 12.28 5.35 2.38 0.9
Davidson south 10 100.0 44.32 15.66 6.98 3.12 1.69 0.73
VCU west 7 100.0 49.6 19.03 8.63 4.28 1.81 0.71
Maryland midwest 4 100.0 50.87 22.22 9.44 3.6 1.86 0.7
Oregon west 8 100.0 58.41 24.89 10.74 4.78 1.74 0.66
Stephen F. Austin south 12 100.0 42.08 23.6 11.54 4.51 1.72 0.63
St. John's south 9 100.0 47.85 18.82 9.51 3.97 1.83 0.62
Dayton east 11 100.0 48.81 21.64 8.96 4.31 1.79 0.58
Mississippi west 11 100.0 43.57 21.86 8.38 3.0 1.41 0.55
Purdue midwest 9 100.0 49.42 20.37 9.7 3.31 1.33 0.53
Buffalo midwest 12 100.0 41.34 21.68 7.93 2.77 1.19 0.52
Valparaiso midwest 13 100.0 49.13 22.69 9.34 4.12 1.49 0.51
Providence east 6 100.0 51.19 26.68 11.18 4.28 1.4 0.48
LSU east 9 100.0 48.81 15.79 7.11 2.58 0.92 0.47
Georgia east 10 100.0 40.33 15.12 7.58 2.95 1.3 0.46
Oklahoma St. west 9 100.0 41.59 18.78 9.24 3.35 1.1 0.45
Wofford west 12 100.0 42.34 16.57 7.37 2.63 0.94 0.44
Indiana midwest 10 100.0 43.06 18.98 8.46 3.72 1.2 0.43
UCLA south 11 100.0 44.65 21.4 8.22 2.72 1.26 0.42
North Carolina St. east 8 100.0 51.19 22.31 8.99 3.55 1.45 0.4
Harvard west 13 100.0 41.65 19.97 8.53 2.49 0.8 0.35
UC Irvine east 13 100.0 44.51 20.52 7.19 2.44 0.97 0.26
Coastal Carolina west 16 100.0 32.33 13.31 5.48 2.24 0.57 0.24
Georgia St. west 14 100.0 43.37 17.27 6.04 1.92 0.47 0.21
UAB south 14 100.0 39.94 12.39 4.94 1.57 0.73 0.17
Eastern Washington south 13 100.0 43.25 12.42 3.88 1.27 0.55 0.17
Lafayette east 16 100.0 34.47 16.19 7.11 2.28 0.5 0.15
Wyoming east 12 100.0 37.73 12.88 3.65 1.12 0.4 0.15
Albany east 14 100.0 38.0 13.94 4.57 1.84 0.53 0.11
Robert Morris south 16 100.0 39.9 16.56 6.97 2.39 0.5 0.11
Belmont east 15 100.0 36.24 13.78 4.7 1.08 0.31 0.11
Texas Southern west 15 100.0 37.43 12.58 4.71 1.27 0.25 0.11
Northeastern midwest 14 100.0 38.88 14.12 4.28 0.99 0.29 0.09
Hampton midwest 16 100.0 41.31 14.5 4.91 1.25 0.25 0.07
North Dakota St. south 15 100.0 42.02 19.33 7.53 1.74 0.33 0.05
New Mexico St. midwest 15 100.0 33.43 13.3 3.85 1.16 0.31 0.05

That is, indeed, high temperature! Let's try it with a bunch more runs

In [14]:
results = MMMC.runbracket1(ntrials=100000,T=1.5)
Lowest energy bracket
Kentucky (1)                                                                   
Hampton (16)              Ken (1)                                              
Cincinnati (8)                                                                 
Purdue (9)                Cin (8)  Ken (1)                                     
West Virginia (5)                                                              
Buffalo (12)              Wes (5)                                              
Maryland (4)                                                                   
Valparaiso (13)           Mar (4)  Wes (5)  Ken (1)                            
Butler (6)                                                                     
Texas (11)                Tex (11)                                             
Notre Dame (3)                                                                 
Northeastern (14)         Not (3)  Not (3)                                     
Wichita St. (7)                                                                
Indiana (10)              Wic (7)                                              
Kansas (2)                                                                     
New Mexico St. (15)       Kan (2)  Kan (2)  Not (3)  Ken (1)                   
Duke (1)                                                                       
Robert Morris (16)        Duk (1)                                              
San Diego St. (8)                                                              
St. John's (9)            San (8)  Duk (1)                                     
Utah (5)                                                                       
Stephen F. Austin (12)    Uta (5)                                              
Georgetown (4)                                                                 
Eastern Washington (13)   Geo (4)  Uta (5)  Duk (1)                            
SMU (6)                                                                        
UCLA (11)                 SMU (6)                                              
Iowa St. (3)                                                                   
UAB (14)                  Iow (3)  Iow (3)                                     
Iowa (7)                                                                       
Davidson (10)             Iow (7)                                              
Gonzaga (2)                                                                    
North Dakota St. (15)     Gon (2)  Gon (2)  Gon (2)  Gon (2)  Ken (1)          
Wisconsin (1)             Wis (1)  Wis (1)  Wis (1)  Ari (2)  Ari (2)  Ken (1) 
Coastal Carolina (16)                                                          
Oregon (8)                Okl (9)                                              
Oklahoma St. (9)                                                               
Arkansas (5)              Ark (5)  Nor (4)                                     
Wofford (12)                                                                   
North Carolina (4)        Nor (4)                                              
Harvard (13)                                                                   
Xavier (6)                Xav (6)  Bay (3)  Ari (2)                            
Mississippi (11)                                                               
Baylor (3)                Bay (3)                                              
Georgia St. (14)                                                               
VCU (7)                   Ohi (10) Ari (2)                                     
Ohio St. (10)                                                                  
Arizona (2)               Ari (2)                                              
Texas Southern (15)                                                            
Villanova (1)             Vil (1)  Vil (1)  Vil (1)  Vir (2)                   
Lafayette (16)                                                                 
North Carolina St. (8)    Nor (8)                                              
LSU (9)                                                                        
Northern Iowa (5)         Nor (5)  Nor (5)                                     
Wyoming (12)                                                                   
Louisville (4)            Lou (4)                                              
UC Irvine (13)                                                                 
Providence (6)            Pro (6)  Okl (3)  Vir (2)                            
Dayton (11)                                                                    
Oklahoma (3)              Okl (3)                                              
Albany (14)                                                                    
Michigan St. (7)          Mic (7)  Vir (2)                                     
Georgia (10)                                                                   
Virginia (2)              Vir (2)                                              
Belmont (15)                                                                   
Total bracket energy: -44.697443432

Most common bracket (9)
Kentucky (1)                                                                   
Hampton (16)              Ken (1)                                              
Cincinnati (8)                                                                 
Purdue (9)                Cin (8)  Ken (1)                                     
West Virginia (5)                                                              
Buffalo (12)              Buf (12)                                             
Maryland (4)                                                                   
Valparaiso (13)           Val (13) Buf (12) Ken (1)                            
Butler (6)                                                                     
Texas (11)                Tex (11)                                             
Notre Dame (3)                                                                 
Northeastern (14)         Nor (14) Nor (14)                                    
Wichita St. (7)                                                                
Indiana (10)              Wic (7)                                              
Kansas (2)                                                                     
New Mexico St. (15)       Kan (2)  Wic (7)  Wic (7)  Ken (1)                   
Duke (1)                                                                       
Robert Morris (16)        Rob (16)                                             
San Diego St. (8)                                                              
St. John's (9)            St. (9)  St. (9)                                     
Utah (5)                                                                       
Stephen F. Austin (12)    Ste (12)                                             
Georgetown (4)                                                                 
Eastern Washington (13)   Eas (13) Eas (13) St. (9)                            
SMU (6)                                                                        
UCLA (11)                 SMU (6)                                              
Iowa St. (3)                                                                   
UAB (14)                  Iow (3)  Iow (3)                                     
Iowa (7)                                                                       
Davidson (10)             Dav (10)                                             
Gonzaga (2)                                                                    
North Dakota St. (15)     Nor (15) Dav (10) Iow (3)  Iow (3)  Ken (1)          
Wisconsin (1)             Wis (1)  Wis (1)  Ark (5)  Ark (5)  Vir (2)  Vir (2) 
Coastal Carolina (16)                                                          
Oregon (8)                Okl (9)                                              
Oklahoma St. (9)                                                               
Arkansas (5)              Ark (5)  Ark (5)                                     
Wofford (12)                                                                   
North Carolina (4)        Nor (4)                                              
Harvard (13)                                                                   
Xavier (6)                Xav (6)  Bay (3)  Bay (3)                            
Mississippi (11)                                                               
Baylor (3)                Bay (3)                                              
Georgia St. (14)                                                               
VCU (7)                   Ohi (10) Ohi (10)                                    
Ohio St. (10)                                                                  
Arizona (2)               Ari (2)                                              
Texas Southern (15)                                                            
Villanova (1)             Vil (1)  Vil (1)  Lou (4)  Vir (2)                   
Lafayette (16)                                                                 
North Carolina St. (8)    LSU (9)                                              
LSU (9)                                                                        
Northern Iowa (5)         Nor (5)  Lou (4)                                     
Wyoming (12)                                                                   
Louisville (4)            Lou (4)                                              
UC Irvine (13)                                                                 
Providence (6)            Day (11) Alb (14) Vir (2)                            
Dayton (11)                                                                    
Oklahoma (3)              Alb (14)                                             
Albany (14)                                                                    
Michigan St. (7)          Mic (7)  Vir (2)                                     
Georgia (10)                                                                   
Virginia (2)              Vir (2)                                              
Belmont (15)                                                                   
Total bracket energy: -37.1483683417

In [15]:
h = HTML(MMMC.maketable(results))
h
Out[15]:
Team Region Rank 2nd Round 3rd Round Sweet 16 Elite 8 Final 4 Championship Win
Kentucky midwest 1 100.0 67.848 49.189 36.444 26.79 18.949 12.828
Arizona west 2 100.0 64.114 42.628 29.248 18.838 12.256 7.805
Wisconsin west 1 100.0 63.368 42.146 28.131 17.705 11.083 6.862
Villanova east 1 100.0 64.314 43.814 28.618 17.425 10.64 6.365
Virginia east 2 100.0 62.189 39.522 26.285 17.038 10.321 6.183
Gonzaga south 2 100.0 61.672 38.305 24.17 14.417 8.149 4.538
Duke south 1 100.0 64.407 40.263 24.75 14.927 8.061 4.37
Oklahoma east 3 100.0 62.257 38.005 20.227 11.564 5.906 3.04
Utah south 5 100.0 56.188 34.295 19.469 10.846 5.576 2.832
Notre Dame midwest 3 100.0 60.692 33.504 18.74 9.665 5.061 2.473
Kansas midwest 2 100.0 59.732 33.553 18.682 9.098 4.834 2.329
Northern Iowa east 5 100.0 58.928 34.06 17.509 9.302 4.604 2.239
North Carolina west 4 100.0 61.148 36.852 19.086 9.535 4.682 2.223
Iowa St. south 3 100.0 59.581 33.405 18.131 9.562 4.647 2.206
Baylor west 3 100.0 58.599 34.549 16.969 9.177 4.63 2.202
Wichita St. midwest 7 100.0 56.45 31.005 17.065 8.454 4.378 2.104
Louisville east 4 100.0 56.525 30.188 15.331 6.889 3.158 1.413
Texas midwest 11 100.0 52.783 28.184 14.644 6.604 3.115 1.372
SMU south 6 100.0 54.37 29.068 14.489 6.789 3.097 1.361
Georgetown south 4 100.0 58.912 28.238 14.08 6.915 3.015 1.311
Michigan St. east 7 100.0 55.477 25.467 12.998 6.372 2.951 1.292
Ohio St. west 10 100.0 50.1 23.617 12.158 5.813 2.825 1.18
West Virginia midwest 5 100.0 52.507 28.241 12.365 5.829 2.809 1.09
Butler midwest 6 100.0 47.217 24.427 12.449 5.551 2.47 1.088
Iowa south 7 100.0 51.023 24.916 12.842 6.02 2.641 1.084
Arkansas west 5 100.0 58.71 28.683 13.046 5.712 2.619 1.074
San Diego St. south 8 100.0 52.821 25.262 12.281 5.721 2.585 1.026
Xavier west 6 100.0 52.833 26.252 11.254 5.424 2.318 0.966
VCU west 7 100.0 49.9 22.655 11.034 5.322 2.272 0.915
Davidson south 10 100.0 48.977 23.746 11.654 5.393 2.259 0.887
Maryland midwest 4 100.0 54.293 27.841 10.992 4.69 2.124 0.852
Cincinnati midwest 8 100.0 49.481 21.064 10.878 4.977 2.137 0.809
Providence east 6 100.0 50.52 23.839 10.379 4.86 1.981 0.778
North Carolina St. east 8 100.0 52.32 22.887 11.35 4.862 1.818 0.717
Oregon west 8 100.0 50.892 22.58 10.956 4.322 1.844 0.7
St. John's south 9 100.0 47.179 22.962 10.652 4.691 1.904 0.687
Stephen F. Austin south 12 100.0 43.812 22.666 9.837 4.551 1.859 0.674
Oklahoma St. west 9 100.0 49.108 21.697 10.965 4.484 1.736 0.666
Georgia east 10 100.0 44.523 21.647 10.237 4.523 1.723 0.65
Dayton east 11 100.0 49.48 22.922 9.937 4.078 1.609 0.594
LSU east 9 100.0 47.68 20.72 9.64 3.961 1.595 0.584
UCLA south 11 100.0 45.63 22.264 9.285 3.921 1.548 0.559
Mississippi west 11 100.0 47.167 20.522 8.975 3.684 1.45 0.53
Buffalo midwest 12 100.0 47.493 23.217 8.816 3.647 1.519 0.525
Purdue midwest 9 100.0 50.519 19.548 9.389 3.926 1.513 0.503
Indiana midwest 10 100.0 43.55 19.487 8.32 3.427 1.3 0.446
Valparaiso midwest 13 100.0 45.707 20.701 8.106 3.225 1.236 0.43
Georgia St. west 14 100.0 41.401 18.677 6.87 2.788 0.94 0.321
Harvard west 13 100.0 38.852 17.912 7.032 2.36 0.872 0.269
UC Irvine east 13 100.0 43.475 18.635 7.212 2.373 0.699 0.232
Wofford west 12 100.0 41.29 16.553 5.962 2.169 0.686 0.214
Wyoming east 12 100.0 41.072 17.117 6.21 2.154 0.697 0.194
New Mexico St. midwest 15 100.0 40.268 15.955 5.428 1.908 0.604 0.167
UAB south 14 100.0 40.419 15.263 4.757 1.649 0.545 0.153
Northeastern midwest 14 100.0 39.308 13.885 4.672 1.41 0.479 0.145
Belmont east 15 100.0 37.811 13.364 4.884 1.732 0.534 0.144
Albany east 14 100.0 37.743 15.234 5.053 1.602 0.465 0.14
Eastern Washington south 13 100.0 41.088 14.801 5.269 1.861 0.544 0.139
Coastal Carolina west 16 100.0 36.632 13.577 4.822 1.707 0.492 0.126
North Dakota St. south 15 100.0 38.328 13.033 4.672 1.602 0.478 0.121
Lafayette east 16 100.0 35.686 12.579 4.13 1.265 0.31 0.078
Robert Morris south 16 100.0 35.593 11.513 3.662 1.135 0.33 0.073
Texas Southern west 15 100.0 35.886 11.1 3.492 0.96 0.284 0.066
Hampton midwest 16 100.0 32.152 10.199 3.01 0.799 0.234 0.056
In [17]:
MMMC.showstats(results['all'],description='full run',newfig=True)

Not bad! (Also, note the shape of the energy distribution, and the fact taht the "Unique brackets" group is still basically linear!)

Who wins?

But let's be honest for a minute. We all know Kansas is going to win. What do the brackets where that happened look like?

In [18]:
goodbrackets = [i for i in results['all'].brackets if i.bracket[-1][0] == 'Kansas']
In [19]:
from MarchMadnessMonteCarlo.Brackets import Stats
lb, mcb, mcb_count, unique_brackets, lowest_sightings = Stats.gather_uniquestats(goodbrackets)
sr = MMMC.SimulationResults(goodbrackets,unique_brackets,lb,lowest_sightings,mcb,mcb_count)
trueresults = {'all':sr}
In [20]:
h = HTML(MMMC.maketable(trueresults))
h
Out[20]:
Team Region Rank 2nd Round 3rd Round Sweet 16 Elite 8 Final 4 Championship Win
Kansas midwest 2 100.0 100.0 100.0 100.0 100.0 100.0 100.0
Virginia east 2 100.0 61.743237441 39.7595534564 25.7621296694 17.1318162301 9.01674538429 0.0
Villanova east 1 100.0 68.05495921 47.8316874195 30.8286818377 17.3894375268 8.71618720481 0.0
Wisconsin west 1 100.0 62.0008587377 39.5019321597 24.9033920137 14.2121082009 8.2438814942 0.0
Oklahoma east 3 100.0 63.8042078145 42.7221983684 22.4130528124 13.0957492486 7.7715757836 0.0
Arizona west 2 100.0 62.9025332761 37.5697724345 24.4310863031 14.6414770288 7.72863890082 0.0
Northern Iowa east 5 100.0 59.5534564191 37.1404036067 18.3769858308 10.5195362817 5.45298411335 0.0
Baylor west 3 100.0 55.3456419064 30.9145556033 15.5431515672 9.05968226707 4.89480463718 0.0
North Carolina west 4 100.0 58.8664662945 35.4229282954 19.321597252 9.61786174324 4.8518677544 0.0
Michigan St. east 7 100.0 57.4924860455 26.4920566767 12.7951910691 6.26878488622 3.47788750537 0.0
Louisville east 4 100.0 58.3082868184 29.2400171748 14.1262344354 6.82696436239 3.30613997424 0.0
Xavier west 6 100.0 50.1502790897 25.1610133104 11.9793902963 7.29927007299 3.17732932589 0.0
Oregon west 8 100.0 52.2112494633 22.4559896951 12.2799484757 5.28123658222 2.9197080292 0.0
Ohio St. west 10 100.0 50.493774152 26.8355517389 13.6539287248 5.53885787892 2.79089738085 0.0
Arkansas west 5 100.0 60.3263203091 28.9823958781 11.8935165307 5.88235294118 2.70502361529 0.0
VCU west 7 100.0 49.506225848 23.5723486475 12.1082009446 5.83941605839 2.53327608416 0.0
Providence east 6 100.0 51.1807642765 21.4255045084 9.44611421211 4.46543580936 2.44740231859 0.0
North Carolina St. east 8 100.0 55.3885787892 24.6887075998 13.009875483 4.8518677544 2.14684413912 0.0
Mississippi west 11 100.0 49.8497209103 24.6887075998 10.9489051095 4.76599398884 1.9321597252 0.0
Dayton east 11 100.0 48.8192357235 20.0085873766 9.14555603263 4.03606698154 1.9321597252 0.0
Oklahoma St. west 9 100.0 47.7887505367 22.0695577501 11.5500214684 4.20781451267 1.71747531129 0.0
Georgia St. west 14 100.0 44.6543580936 19.2357234865 7.64276513525 3.82138256763 1.71747531129 0.0
Georgia east 10 100.0 42.5075139545 20.6097037355 9.40317732933 3.60669815371 1.63160154573 0.0
Harvard west 13 100.0 41.1335337055 20.0515242593 8.41562902533 3.34907685702 1.58866466295 0.0
Wofford west 12 100.0 39.6736796909 15.5431515672 5.88235294118 2.9197080292 1.37398024903 0.0
LSU east 9 100.0 44.6114212108 18.3769858308 8.75912408759 3.69257191928 1.33104336625 0.0
Belmont east 15 100.0 38.256762559 13.1386861314 6.65521683126 2.10390725633 1.07342206956 0.0
Coastal Carolina west 16 100.0 37.9991412623 15.972520395 5.75354229283 2.36152855303 0.901674538429 0.0
Wyoming east 12 100.0 40.4465435809 17.1747531129 5.5817947617 1.71747531129 0.686990124517 0.0
UC Irvine east 13 100.0 41.6917131816 16.4448261056 5.66766852726 1.63160154573 0.515242593388 0.0
Texas Southern west 15 100.0 37.0974667239 12.022327179 3.69257191928 1.2022327179 0.515242593388 0.0
Lafayette east 16 100.0 31.94504079 9.10261914985 3.6496350365 1.15929583512 0.472305710605 0.0
Albany east 14 100.0 36.1957921855 15.8437097467 4.3795620438 1.50279089738 0.429368827823 0.0
Duke south 1 100.0 61.8291112065 40.1459854015 22.1124946329 13.5680549592 0.0 0.0
Gonzaga south 2 100.0 55.5173894375 35.0364963504 21.4684413912 10.0472305711 0.0 0.0
Utah south 5 100.0 54.8733361958 30.184628596 15.8866466295 9.7037355088 0.0 0.0
Iowa St. south 3 100.0 59.167024474 32.546157149 17.9905538858 9.36024044654 0.0 0.0
Georgetown south 4 100.0 58.780592529 30.184628596 16.1013310434 8.54443967368 0.0 0.0
St. John's south 9 100.0 49.0339201374 23.7011592958 13.7827393731 6.86990124517 0.0 0.0
Stephen F. Austin south 12 100.0 45.1266638042 24.9033920137 10.261914985 6.39759553456 0.0 0.0
SMU south 6 100.0 54.6157148991 27.6513525118 13.8686131387 6.35465865178 0.0 0.0
Davidson south 10 100.0 48.6045513096 24.3022756548 12.022327179 5.5817947617 0.0 0.0
San Diego St. south 8 100.0 50.9660798626 22.6706741091 12.2799484757 5.49592099614 0.0 0.0
Iowa south 7 100.0 51.3954486904 24.4740231859 12.5375697724 5.45298411335 0.0 0.0
UCLA south 11 100.0 45.3842851009 23.1000429369 11.1635895234 5.06655216831 0.0 0.0
Eastern Washington south 13 100.0 41.219407471 14.7273507943 5.88235294118 2.49033920137 0.0 0.0
North Dakota St. south 15 100.0 44.4826105625 16.1872048089 6.18291112065 2.06097037355 0.0 0.0
UAB south 14 100.0 40.832975526 16.7024474023 4.76599398884 1.84628595964 0.0 0.0
Robert Morris south 16 100.0 38.1708887935 13.4821811936 3.69257191928 1.15929583512 0.0 0.0
Kentucky midwest 1 100.0 61.743237441 39.6307428081 21.8119364534 0.0 0.0 0.0
Maryland midwest 4 100.0 59.4246457707 31.2151137827 16.3160154573 0.0 0.0 0.0
Purdue midwest 9 100.0 55.7320738514 27.4796049807 13.3963074281 0.0 0.0 0.0
Buffalo midwest 12 100.0 47.7458136539 24.4310863031 12.2799484757 0.0 0.0 0.0
West Virginia midwest 5 100.0 52.2541863461 23.7440961786 11.8076427651 0.0 0.0 0.0
Valparaiso midwest 13 100.0 40.5753542293 20.6097037355 9.9613568055 0.0 0.0 0.0
Cincinnati midwest 8 100.0 44.2679261486 20.5238299699 9.9613568055 0.0 0.0 0.0
Hampton midwest 16 100.0 38.256762559 12.3658222413 4.46543580936 0.0 0.0 0.0
Texas midwest 11 100.0 51.5671962216 30.9145556033 0.0 0.0 0.0 0.0
Notre Dame midwest 3 100.0 58.4800343495 30.2275654787 0.0 0.0 0.0 0.0
Butler midwest 6 100.0 48.4328037784 23.0141691713 0.0 0.0 0.0 0.0
Northeastern midwest 14 100.0 41.5199656505 15.8437097467 0.0 0.0 0.0 0.0
Wichita St. midwest 7 100.0 55.2168312581 0.0 0.0 0.0 0.0 0.0
Indiana midwest 10 100.0 44.7831687419 0.0 0.0 0.0 0.0 0.0
New Mexico St. midwest 15 100.0 0.0 0.0 0.0 0.0 0.0 0.0
In [21]:
sr.most_common_bracket
Out[21]:
Kentucky (1)                                                                   
Hampton (16)              Ham (16)                                             
Cincinnati (8)                                                                 
Purdue (9)                Pur (9)  Pur (9)                                     
West Virginia (5)                                                              
Buffalo (12)              Buf (12)                                             
Maryland (4)                                                                   
Valparaiso (13)           Val (13) Buf (12) Pur (9)                            
Butler (6)                                                                     
Texas (11)                Tex (11)                                             
Notre Dame (3)                                                                 
Northeastern (14)         Not (3)  Not (3)                                     
Wichita St. (7)                                                                
Indiana (10)              Ind (10)                                             
Kansas (2)                                                                     
New Mexico St. (15)       Kan (2)  Kan (2)  Kan (2)  Kan (2)                   
Duke (1)                                                                       
Robert Morris (16)        Duk (1)                                              
San Diego St. (8)                                                              
St. John's (9)            St. (9)  Duk (1)                                     
Utah (5)                                                                       
Stephen F. Austin (12)    Ste (12)                                             
Georgetown (4)                                                                 
Eastern Washington (13)   Geo (4)  Ste (12) Ste (12)                           
SMU (6)                                                                        
UCLA (11)                 SMU (6)                                              
Iowa St. (3)                                                                   
UAB (14)                  Iow (3)  SMU (6)                                     
Iowa (7)                                                                       
Davidson (10)             Iow (7)                                              
Gonzaga (2)                                                                    
North Dakota St. (15)     Gon (2)  Gon (2)  Gon (2)  Ste (12) Kan (2)          
Wisconsin (1)             Wis (1)  Okl (9)  Wof (12) Wof (12) Okl (3)  Kan (2) 
Coastal Carolina (16)                                                          
Oregon (8)                Okl (9)                                              
Oklahoma St. (9)                                                               
Arkansas (5)              Wof (12) Wof (12)                                    
Wofford (12)                                                                   
North Carolina (4)        Har (13)                                             
Harvard (13)                                                                   
Xavier (6)                Xav (6)  Bay (3)  Ari (2)                            
Mississippi (11)                                                               
Baylor (3)                Bay (3)                                              
Georgia St. (14)                                                               
VCU (7)                   Ohi (10) Ari (2)                                     
Ohio St. (10)                                                                  
Arizona (2)               Ari (2)                                              
Texas Southern (15)                                                            
Villanova (1)             Laf (16) Nor (8)  Nor (8)  Okl (3)                   
Lafayette (16)                                                                 
North Carolina St. (8)    Nor (8)                                              
LSU (9)                                                                        
Northern Iowa (5)         Wyo (12) Lou (4)                                     
Wyoming (12)                                                                   
Louisville (4)            Lou (4)                                              
UC Irvine (13)                                                                 
Providence (6)            Pro (6)  Okl (3)  Okl (3)                            
Dayton (11)                                                                    
Oklahoma (3)              Okl (3)                                              
Albany (14)                                                                    
Michigan St. (7)          Mic (7)  Mic (7)                                     
Georgia (10)                                                                   
Virginia (2)              Vir (2)                                              
Belmont (15)                                                                   
Total bracket energy: -35.9796902956
In [22]:
sr.most_common_bracket_count
Out[22]:
4

Huh. Well, that's not exactly my pick for best bracket, but there you have it.

Excersizes for the reader:

  • make a better energy function, using maybe a weighted average of different rankings. I slurped in KenPom and Jeff Sagarin, but you could add your own.
  • come up with a better "hometown wins" version. E.g. explicitly check for KU, and tweak the rankings.
In [46]:
from MarchMadnessMonteCarlo import RankingsAndStrength as RAS
strength = RAS.kenpom['Pyth']
jsstrength = RAS.sagarin['Rating']

def weighted_KU_energy_game(winner, loser):
    if winner == 'Kansas':
        win_pct = 0.99
    elif loser == 'Kansas':
        win_pct = 0.01
    else:
        A,B = strength[winner],strength[loser]
        # see http://207.56.97.150/articles/playoff2002.htm
        kenpom = (A-A*B)/(A+B-2*A*B)
        A,B = jsstrength[winner]/100, jsstrength[loser]/100
        A,B = min(A,0.9999),min(B,0.9999)
        sagarin = (A-A*B)/(A+B-2*A*B)
        win_pct = 0.70*kenpom + 0.30*sagarin
    return -win_pct
In [48]:
MMMC.set_energy_function(weighted_KU_energy_game)
In [55]:
results = MMMC.runbracket1(ntrials=100000,T=1.5)
Lowest energy bracket
Kentucky (1)                                                                   
Hampton (16)              Ken (1)                                              
Cincinnati (8)                                                                 
Purdue (9)                Cin (8)  Ken (1)                                     
West Virginia (5)                                                              
Buffalo (12)              Wes (5)                                              
Maryland (4)                                                                   
Valparaiso (13)           Mar (4)  Wes (5)  Ken (1)                            
Butler (6)                                                                     
Texas (11)                Tex (11)                                             
Notre Dame (3)                                                                 
Northeastern (14)         Not (3)  Not (3)                                     
Wichita St. (7)                                                                
Indiana (10)              Wic (7)                                              
Kansas (2)                                                                     
New Mexico St. (15)       Kan (2)  Kan (2)  Kan (2)  Kan (2)                   
Duke (1)                                                                       
Robert Morris (16)        Duk (1)                                              
San Diego St. (8)                                                              
St. John's (9)            San (8)  Duk (1)                                     
Utah (5)                                                                       
Stephen F. Austin (12)    Uta (5)                                              
Georgetown (4)                                                                 
Eastern Washington (13)   Geo (4)  Uta (5)  Duk (1)                            
SMU (6)                                                                        
UCLA (11)                 SMU (6)                                              
Iowa St. (3)                                                                   
UAB (14)                  Iow (3)  Iow (3)                                     
Iowa (7)                                                                       
Davidson (10)             Iow (7)                                              
Gonzaga (2)                                                                    
North Dakota St. (15)     Gon (2)  Gon (2)  Gon (2)  Duk (1)  Kan (2)          
Wisconsin (1)             Wis (1)  Wis (1)  Wis (1)  Ari (2)  Ari (2)  Kan (2) 
Coastal Carolina (16)                                                          
Oregon (8)                Okl (9)                                              
Oklahoma St. (9)                                                               
Arkansas (5)              Ark (5)  Nor (4)                                     
Wofford (12)                                                                   
North Carolina (4)        Nor (4)                                              
Harvard (13)                                                                   
Xavier (6)                Xav (6)  Bay (3)  Ari (2)                            
Mississippi (11)                                                               
Baylor (3)                Bay (3)                                              
Georgia St. (14)                                                               
VCU (7)                   Ohi (10) Ari (2)                                     
Ohio St. (10)                                                                  
Arizona (2)               Ari (2)                                              
Texas Southern (15)                                                            
Villanova (1)             Vil (1)  Vil (1)  Vil (1)  Vir (2)                   
Lafayette (16)                                                                 
North Carolina St. (8)    Nor (8)                                              
LSU (9)                                                                        
Northern Iowa (5)         Nor (5)  Nor (5)                                     
Wyoming (12)                                                                   
Louisville (4)            Lou (4)                                              
UC Irvine (13)                                                                 
Providence (6)            Pro (6)  Okl (3)  Vir (2)                            
Dayton (11)                                                                    
Oklahoma (3)              Okl (3)                                              
Albany (14)                                                                    
Michigan St. (7)          Mic (7)  Vir (2)                                     
Georgia (10)                                                                   
Virginia (2)              Vir (2)                                              
Belmont (15)                                                                   
Total bracket energy: -45.7476455682

Most common bracket (13)
Kentucky (1)                                                                   
Hampton (16)              Ken (1)                                              
Cincinnati (8)                                                                 
Purdue (9)                Pur (9)  Pur (9)                                     
West Virginia (5)                                                              
Buffalo (12)              Buf (12)                                             
Maryland (4)                                                                   
Valparaiso (13)           Mar (4)  Buf (12) Buf (12)                           
Butler (6)                                                                     
Texas (11)                But (6)                                              
Notre Dame (3)                                                                 
Northeastern (14)         Not (3)  Not (3)                                     
Wichita St. (7)                                                                
Indiana (10)              Wic (7)                                              
Kansas (2)                                                                     
New Mexico St. (15)       Kan (2)  Kan (2)  Kan (2)  Kan (2)                   
Duke (1)                                                                       
Robert Morris (16)        Duk (1)                                              
San Diego St. (8)                                                              
St. John's (9)            San (8)  San (8)                                     
Utah (5)                                                                       
Stephen F. Austin (12)    Ste (12)                                             
Georgetown (4)                                                                 
Eastern Washington (13)   Geo (4)  Ste (12) San (8)                            
SMU (6)                                                                        
UCLA (11)                 SMU (6)                                              
Iowa St. (3)                                                                   
UAB (14)                  UAB (14) UAB (14)                                    
Iowa (7)                                                                       
Davidson (10)             Iow (7)                                              
Gonzaga (2)                                                                    
North Dakota St. (15)     Gon (2)  Gon (2)  Gon (2)  Gon (2)  Kan (2)          
Wisconsin (1)             Coa (16) Okl (9)  Nor (4)  Ari (2)  Ari (2)  Kan (2) 
Coastal Carolina (16)                                                          
Oregon (8)                Okl (9)                                              
Oklahoma St. (9)                                                               
Arkansas (5)              Wof (12) Nor (4)                                     
Wofford (12)                                                                   
North Carolina (4)        Nor (4)                                              
Harvard (13)                                                                   
Xavier (6)                Mis (11) Mis (11) Ari (2)                            
Mississippi (11)                                                               
Baylor (3)                Bay (3)                                              
Georgia St. (14)                                                               
VCU (7)                   VCU (7)  Ari (2)                                     
Ohio St. (10)                                                                  
Arizona (2)               Ari (2)                                              
Texas Southern (15)                                                            
Villanova (1)             Vil (1)  Nor (8)  Nor (8)  Nor (8)                   
Lafayette (16)                                                                 
North Carolina St. (8)    Nor (8)                                              
LSU (9)                                                                        
Northern Iowa (5)         Nor (5)  Lou (4)                                     
Wyoming (12)                                                                   
Louisville (4)            Lou (4)                                              
UC Irvine (13)                                                                 
Providence (6)            Pro (6)  Okl (3)  Mic (7)                            
Dayton (11)                                                                    
Oklahoma (3)              Okl (3)                                              
Albany (14)                                                                    
Michigan St. (7)          Mic (7)  Mic (7)                                     
Georgia (10)                                                                   
Virginia (2)              Bel (15)                                             
Belmont (15)                                                                   
Total bracket energy: -38.9077921757

In [56]:
MMMC.showstats(results['all'],description='full run',newfig=True)
In [57]:
h = HTML(MMMC.maketable(results))
h
Out[57]:
Team Region Rank 2nd Round 3rd Round Sweet 16 Elite 8 Final 4 Championship Win
Kansas midwest 2 100.0 71.415 55.343 44.429 35.557 28.44 22.414
Kentucky midwest 1 100.0 69.107 50.644 37.446 18.891 13.788 9.643
Arizona west 2 100.0 65.022 43.251 29.626 19.515 12.801 6.535
Wisconsin west 1 100.0 64.476 43.066 29.09 17.775 11.201 5.467
Virginia east 2 100.0 65.076 42.901 28.131 17.706 10.58 5.127
Villanova east 1 100.0 63.795 42.213 27.546 17.299 10.203 4.848
Duke south 1 100.0 63.066 40.645 25.96 15.924 6.731 3.64
Gonzaga south 2 100.0 62.557 37.869 24.019 14.332 6.157 3.354
Utah south 5 100.0 54.831 33.958 18.603 10.684 4.171 2.105
North Carolina west 4 100.0 55.798 35.168 18.059 9.103 4.648 1.857
Oklahoma east 3 100.0 57.558 32.89 16.602 8.699 4.476 1.856
Iowa St. south 3 100.0 58.435 32.387 17.002 9.079 3.519 1.74
Baylor west 3 100.0 57.425 33.143 16.356 8.703 4.328 1.714
Northern Iowa east 5 100.0 58.362 33.246 16.966 8.687 4.148 1.653
Notre Dame midwest 3 100.0 58.973 33.146 12.23 5.888 3.064 1.459
Louisville east 4 100.0 56.572 30.948 15.201 7.349 3.329 1.289
Wichita St. midwest 7 100.0 55.022 19.553 10.731 5.057 2.614 1.235
Michigan St. east 7 100.0 53.365 25.012 13.642 6.637 3.041 1.157
Ohio St. west 10 100.0 50.97 23.373 12.8 6.241 2.876 1.053
Georgetown south 4 100.0 56.351 27.242 13.727 6.735 2.386 1.046
SMU south 6 100.0 50.545 26.664 12.96 6.318 2.197 0.98
Iowa south 7 100.0 53.959 26.803 13.763 6.446 2.273 0.979
Xavier west 6 100.0 54.002 25.958 11.422 5.532 2.541 0.936
West Virginia midwest 5 100.0 55.439 30.487 13.026 4.733 2.187 0.896
Providence east 6 100.0 54.017 27.975 12.282 5.736 2.417 0.88
Arkansas west 5 100.0 55.043 25.753 11.997 5.229 2.275 0.845
Texas midwest 11 100.0 51.713 25.828 9.107 4.172 1.938 0.84
San Diego St. south 8 100.0 49.116 22.93 11.033 5.181 1.853 0.755
VCU west 7 100.0 49.03 21.187 9.927 4.523 1.995 0.744
Maryland midwest 4 100.0 53.53 26.132 10.837 4.056 1.82 0.735
Butler midwest 6 100.0 48.287 23.838 8.227 3.593 1.688 0.694
Davidson south 10 100.0 46.041 21.646 10.642 4.871 1.683 0.678
Oklahoma St. west 9 100.0 50.857 22.453 11.343 4.682 1.87 0.671
North Carolina St. east 8 100.0 51.914 22.439 11.07 4.813 1.896 0.611
St. John's south 9 100.0 50.884 23.054 10.411 4.442 1.496 0.575
Stephen F. Austin south 12 100.0 45.169 22.367 9.957 4.368 1.439 0.568
Georgia east 10 100.0 46.635 19.336 9.623 4.499 1.597 0.567
Oregon west 8 100.0 49.143 20.518 9.907 4.144 1.678 0.559
UCLA south 11 100.0 49.455 24.063 10.453 4.388 1.575 0.554
LSU east 9 100.0 48.086 20.5 9.842 4.191 1.708 0.551
Mississippi west 11 100.0 45.998 21.001 8.299 3.623 1.44 0.541
Cincinnati midwest 8 100.0 52.308 20.082 10.116 3.18 1.382 0.541
Dayton east 11 100.0 45.983 23.105 9.306 3.898 1.639 0.495
Purdue midwest 9 100.0 47.692 18.407 8.311 2.991 1.216 0.453
Buffalo midwest 12 100.0 44.561 22.616 8.681 2.764 1.099 0.392
Indiana midwest 10 100.0 44.978 13.846 5.745 2.269 0.928 0.344
Harvard west 13 100.0 44.202 21.121 7.51 2.602 0.998 0.339
Georgia St. west 14 100.0 42.575 19.898 7.477 2.894 1.147 0.321
Valparaiso midwest 13 100.0 46.47 20.765 7.922 2.461 0.91 0.286
Wyoming east 12 100.0 41.638 18.284 7.123 2.652 0.927 0.268
UC Irvine east 13 100.0 43.428 17.522 6.975 2.726 0.965 0.263
Wofford west 12 100.0 44.957 17.958 6.914 2.297 0.81 0.241
UAB south 14 100.0 41.565 16.886 6.077 2.033 0.673 0.222
Northeastern midwest 14 100.0 41.027 17.188 5.238 1.867 0.626 0.182
Eastern Washington south 13 100.0 43.649 16.433 5.605 1.968 0.527 0.168
New Mexico St. midwest 15 100.0 28.585 11.258 4.293 1.566 0.487 0.165
Albany east 14 100.0 42.442 16.03 5.183 1.709 0.542 0.151
North Dakota St. south 15 100.0 37.443 13.682 5.084 1.791 0.499 0.145
Lafayette east 16 100.0 36.205 14.848 5.277 1.578 0.462 0.142
Belmont east 15 100.0 34.924 12.751 5.231 1.821 0.531 0.139
Coastal Carolina west 16 100.0 35.524 13.963 5.18 1.746 0.538 0.138
Robert Morris south 16 100.0 36.934 13.371 4.704 1.44 0.372 0.1
Texas Southern west 15 100.0 34.978 12.189 4.093 1.391 0.393 0.085
Hampton midwest 16 100.0 30.893 10.867 3.661 0.955 0.262 0.069

Looks good! I'm in!

Comments

Comments powered by Disqus