-
-
Save NaimKabir/108c2992c9c6c8f0f09e2586e641f30f to your computer and use it in GitHub Desktop.
To be even more general, taking into account uniform distributions on overall partyline voting 25% - 75%, Republican non-partyline voting 75% - 95%, and Dem/Indep non-partyline voting 10% - 40%, so a better monte carlo is done over 1000 precincts. The result is largely the same, with even less of a slope, and a bit more scatter. Again, I don't see how the data Dr. Shiva showed is possible. Something is going on in those counties. We need access to the data he is seeing.
import numpy as np
import matplotlib.pyplot as plt
num_precincts = 1000 # let's deal with 1000 precincts.
r_partyline_percentages = np.random.rand(num_precincts) # modeling the fraction of REP PARTYLINE voters in a precint, randomly from [0-1]
p_NR_partyline = 0.5np.random.rand(num_precincts) + 0.25 # prob range of fraction of OVERALL PARTYLINE vote in a precint [0.25-0.75]
p_NR_demindep = 0.3np.random.rand(num_precincts) + 0.1 # prob range of fraction of DEM/INEPPENDENT vote for Trump in a precint [0.1-0.4]
p_NR_rep_non_partyline = 0.2*np.random.rand(num_precincts) + 0.75 # prob range of fraction of REP NON-PARTYLINE vote for Trump in a precint [0.75-0.95]
non_r_pop_size_dem = 100
split_votes_dem = np.random.binomial(non_r_pop_size_dem, p_NR_demindep, num_precincts) # simulating binomial weighted for non-partyline dem/indep
split_trump_percentage_demindep = split_votes_dem / non_r_pop_size_dem
non_r_pop_size_rep = 100
split_votes_rep = np.random.binomial(non_r_pop_size_rep, p_NR_rep_non_partyline, num_precincts) # simulating binomial weighted for non-partyline rep
split_trump_percentage_rep = split_votes_rep / non_r_pop_size_rep
rep_non_partyline_percentages = r_partyline_percentages # assumes Republican voter breakout is the same whether party-line voting or non-partyline
demindep_percentages = (1-rep_non_partyline_percentages) # dem/indepent non-partyline percentage is rest of non-partyline voter population
trump_partyline_percentages = p_NR_partyliner_partyline_percentages # partyline voter tally for trump
trump_nonpartyline_percentages = (1-p_NR_partyline)(split_trump_percentage_reprep_non_partyline_percentages + split_trump_percentage_demindepdemindep_percentages) # non-partyline voter tally for trump
total_trump_vote_percentages = trump_partyline_percentages + trump_nonpartyline_percentages # add total Trump vote up by percentages
diffs = total_trump_vote_percentages - r_partyline_percentages
plt.scatter(r_partyline_percentages100, diffs100)
plt.xlim(0,100)
plt.ylim(-50,50)
plt.xlabel('% republican straight-ticket votes')
plt.ylabel('% individual trump votes - % straight ticket votes')
plt.savefig('diff')
An unreasonable situation, similar to the ones you depict. This didn't happen.
p_NR_partyline = 0.1
p_NR_rep_non_partyline = 0.5
p_NR_demindep = 0.1