#Election Results
import codecademylib
from matplotlib import pyplot as plt
import numpy as np


survey_responses = ['Ceballos', 'Kerrigan', 'Ceballos', 'Ceballos', 'Ceballos','Kerrigan', 'Kerrigan', 'Ceballos', 'Ceballos', 'Ceballos', 
'Kerrigan', 'Kerrigan', 'Ceballos', 'Ceballos', 'Kerrigan', 'Kerrigan', 'Ceballos', 'Ceballos', 'Kerrigan', 'Kerrigan', 'Kerrigan', 'Kerrigan', 'Kerrigan', 'Kerrigan', 'Ceballos', 'Ceballos', 'Ceballos', 'Ceballos', 'Ceballos', 'Ceballos',
'Kerrigan', 'Kerrigan', 'Ceballos', 'Ceballos', 'Ceballos', 'Kerrigan', 'Kerrigan', 'Ceballos', 'Ceballos', 'Kerrigan', 'Kerrigan', 'Ceballos', 'Ceballos', 'Kerrigan', 'Kerrigan', 'Kerrigan', 'Kerrigan', 'Kerrigan', 'Kerrigan', 'Ceballos',
'Kerrigan', 'Kerrigan', 'Ceballos', 'Ceballos', 'Ceballos', 'Kerrigan', 'Kerrigan', 'Ceballos', 'Ceballos', 'Kerrigan', 'Kerrigan', 'Ceballos', 'Ceballos', 'Kerrigan', 'Kerrigan', 'Kerrigan', 'Kerrigan', 'Kerrigan', 'Kerrigan', 'Ceballos']

total_ceballos = survey_responses.count('Ceballos')
print total_ceballos

percentage_ceballos = 100 * total_ceballos / len(survey_responses)
print percentage_ceballos, len(survey_responses)

possible_surveys = np.random.binomial(70, 0.54, size=10000) / 70.
print possible_surveys

plt.hist(possible_surveys, range=(0,1), bins=20)
plt.show()

ceballos_loss_surveys = np.mean(possible_surveys < 0.50)
print ceballos_loss_surveys

large_survey = np.random.binomial(70, 0.54, size=7000) / 70.
print large_survey

ceballos_loss_new = np.mean(large_survey < 0.50)
print ceballos_loss_new