# General Poll for US Presidential Election 2016

We continue our adventure in the Bayesian USA 2016 election forecast through near-ignorance priors.

I will today show how to compute the lower and upepr probabilities for Clinton of winning the general election 2016.
First, we load the lower and upper probabilities for Clinton of winning in every single State (see bayesian-winning-lower-and-upper/) as well as the Electoral Vore for each state

In [5]:
import pandas as pd
In [6]:
#lowerupper
In [7]:

We compute two histograms: one relative to the lower probability and the other relative to the upper probability.
To obtain the histogram of the lower: for each State, we generate a random number r in [0,1] and we assign the electoral vote of the State to Clinton if $r \leq LowerProbability$ in the State or to Trump otherwise.
(same for the upper). We also compute the lower and upper probability that the total electoral votes for Clinton exceeds the break-even line (that is equal to 269)

In [8]:
import numpy as np
#break-even line
evenline=269
#monte Carlo samples
Np=10000

LowElec=np.zeros(Np)
UpElec=np.zeros(Np)
for i in range(0,Np):
lowElec=0
upElec=0
for s in range(0,51):
if np.random.rand(1)<lowerupper['LowerProbability'][s]:
if np.random.rand(1)<lowerupper['UpperProbability'][s]:
LowElec[i]=lowElec
UpElec[i]=upElec
if lowElec>evenline:
if upElec>evenline:

[0.9983,1.0]
In [9]:
import warnings
import datetime as datetime
warnings.filterwarnings('ignore')
%matplotlib inline

import seaborn as sns
import matplotlib.pyplot as plt

sns.distplot(LowElec, axlabel="Electoral Votes (even-line in green)",