The area from 270 and higher (chance of Obama win) is 0.977
The histogram can be reproduced with the following python program:
# Author places this work in the public domain.
import numpy as np
try: import ROOT as r
except: r=None
# state-by-state probabilities of Obama win from November 4, 2012 (http://fivethirtyeight.blogs.nytimes.com)
state_electorsP = {'AL' : ( 9, 0.000), 'ME' : ( 2, 1.000), 'NC' : (15, 0.213),
'AK' : ( 3, 0.001), 'ME1': ( 1, 0.999), 'ND' : ( 3, 0.001),
'AZ' : (11, 0.033), 'ME2': ( 1, 0.900), 'OH' : (18, 0.850),
'AR' : ( 6, 0.000), 'MD' : (10, 1.000), 'OK' : ( 7, 0.000),
'CA' : (55, 1.000), 'MA' : (11, 1.000), 'OR' : ( 7, 0.989),
'CO' : ( 9, 0.681), 'MI' : (16, 0.988), 'PA' : (20, 0.966),
'CT' : ( 7, 0.999), 'MN' : (10, 0.991), 'RI' : ( 4, 1.000),
'DE' : ( 3, 0.998), 'MS' : ( 6, 0.000), 'SC' : ( 9, 0.004),
'DC' : ( 3, 1.000), 'MO' : (10, 0.007), 'SD' : ( 3, 0.005),
'FL' : (29, 0.462), 'MT' : ( 3, 0.020), 'TN' : (11, 0.000),
'GA' : (16, 0.002), 'NE' : ( 2, 0.000), 'TX' : (38, 0.000),
'HI' : ( 4, 1.000), 'NE1': ( 1, 0.005), 'UT' : ( 6, 0.000),
'ID' : ( 4, 0.000), 'NE2': ( 1, 0.133), 'VT' : ( 3, 1.000),
'IL' : (20, 1.000), 'NE3': ( 1, 0.000), 'VA' : (13, 0.710),
'IN' : (11, 0.002), 'NV' : ( 6, 0.895), 'WA' : (12, 0.999),
'IA' : ( 6, 0.831), 'NH' : ( 4, 0.794), 'WV' : ( 5, 0.001),
'KS' : ( 6, 0.001), 'NJ' : (14, 0.998), 'WI' : (10, 0.942),
'KY' : ( 8, 0.000), 'NM' : ( 5, 0.992), 'WY' : ( 3, 0.000),
'LA' : ( 8, 0.000), 'NY' : (29, 1.000),
}
def elector_pdist(ep_pairs) :
'''Recursive construction of electoral probability distribution (no correlations).
With no states, there are zero electors with 100% probability (edge condition);
otherwise, the probability distribution is
* the probability distribution of winning the first state, plus
* the probability distribution of losing the first state.
'''
if not ep_pairs :
return [1.0]
electors,p = ep_pairs[0]
pad = [0.]*electors
sub = elector_pdist(ep_pairs[1:])
return ( np.concatenate( [pad,sub] ) * p + # win (shifted up by #electors won)
np.concatenate( [sub,pad] ) * (1-p) ) # lose (unshifted)
def printText(pdist) :
print "\n%sP(Obama Electors)%s"%(2*('='*50,))
for e,p in enumerate(pdist) :
if not p : continue
i = int(p*1000)
thr = [(4,'.'),(3,':'),(2,'|'),(1,')'),(0,'>')]
cap = next(c for t,c in thr if p*1000-i < 10**(-t))
print ('%3d %s%s'%(e,i*'-',cap)).ljust(80), "%.1e"%p
print '='*100
def printROOT(pdist) :
r.gStyle.SetOptStat('nemi')
c = r.TCanvas()
hist = r.TH1D('p_electors','P(Obama Electors);Obama Electors;',len(pdist),-0.5,len(pdist)-0.05)
win = hist.Clone('p_electors_270+')
win.SetFillColor(r.kBlue)
for e,p in enumerate(pdist) :
hist.SetBinContent(e+1,p)
if e>269 : win.SetBinContent(e+1,p)
hist.Draw('hist'); c.Update()
ps1 = hist.GetListOfFunctions().FindObject("stats")
win.Draw("sames"); c.Update()
ps2 = win.GetListOfFunctions().FindObject("stats")
ps2.SetTextColor(r.kBlue)
ps2.SetY1NDC(0.60)
ps2.SetY2NDC(0.75);
raw_input()
if __name__=='__main__' :
'''Print probabilty distribution of Obama electors and probability of Obama win.'''
p_dist = elector_pdist( state_electorsP.values() )
items = ['sum(e for e,p in state_electorsP.values())', # expect 538
'sum(p_dist)', # expect 1.0
'sum(p_dist[270:])' # Probability of Obama win
]
for item in items : print item.ljust(len(max(items,key=len))), ':', '%.3f'%eval(item)
print
if r : printROOT(p_dist)
else : printText(p_dist)