Problem setup:¶

1. 13,066,047 voters arrive to the polls.
2. $p_{yes}\%$ of them intend to vote "Yes", $(1-p_{yes})\%$ of them intend to vote "No."
3. Each voter casts an invalid (unmarked or void) ballot with probability $p_{invalid}\%$.
4. Of the valid ballots, the poll workers misclassify the vote with probability $p_{misclassification}\%$.
5. Majority vote wins.
In [29]:
%matplotlib inline

In [30]:
import numpy as np

In [37]:
YES_BALLOTS = 6377482
NO_BALLOTS = 6431376
UNMARKED_BALLOTS = 86243
NULL_BALLOTS = 170946

In [38]:
TOTAL_VOTES = YES_BALLOTS + NO_BALLOTS + UNMARKED_BALLOTS + NULL_BALLOTS
P_INVALID = .02
P_MISCLASSIFICATION = .01
N_TRIALS = 100000

In [39]:
def simulate_vote(probability_yes):

invalid_ballots_yes = np.random.binomial(n=yes_votes_samples, p=P_INVALID)
invalid_ballots_no = np.random.binomial(n=no_votes_samples, p=P_INVALID)


In [40]:
for epsilon in [1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-6, 1e-7]:
probability_yes = .5 + epsilon

p_yes: 60.000000% | no_win_percentage: 0.000%