-
-
Save hughdbrown/348023175041691c7511546a1eaeccd9 to your computer and use it in GitHub Desktop.
AZ: (0.3804329085751007, 0.6195670914248993, 332493.15068493155, 541493.1506849315, -209000.00000000003) | |
FL: (0.6779600278494492, 0.3220399721505508, 727637.3626373624, 345637.36263736244, 381999.99999999994) | |
GA: (0.5798898071625344, 0.42011019283746565, 1219448.2758620693, 883448.2758620695, 335999.99999999977) | |
IA: (0.43084455324357407, 0.5691554467564259, 352000.0, 465000.0, -112999.99999999997) | |
MI: (0.5424654351109562, 0.45753456488904376, 1628720.9302325586, 1373720.9302325582, 255000.0000000003) | |
NC: (0.6079855936413314, 0.3920144063586686, 208319.14893617015, 134319.14893617015, 74000.00000000003) | |
OH: (0.6330845907837039, 0.36691540921629606, 711172.8395061726, 412172.8395061726, 299000.0) | |
PA: (0.5496743418035043, 0.4503256581964957, 1997333.333333333, 1636333.333333333, 361000.0) | |
TX: (0.5517922189231381, 0.4482077810768619, 2002944.444444445, 1626944.444444445, 375999.99999999994) | |
WI: (0.5267461143892939, 0.47325388561070614, 718842.105263158, 645842.105263158, 73000.00000000007) | |
This shows Biden carrying Arizona and Iowa and losing Florida, Georgia, Michigan, Ohio, Pennsylvania, Texas, and Wisconsin. | |
Florida, for example, shows Biden needing to get 67.7% of the remaining votes to catch up the 382k votes he would ned to get to tie. |
#!/usr/bin/env python3 | |
def swing(a, b, p): | |
total = (a + b) / p | |
remaining = total - (a + b) | |
x = (remaining + b - a) / (2 * remaining) | |
return (x, 1 - x, x * remaining, (1 - x) * remaining, (2 * x - 1) * remaining) | |
print(f'AZ: {swing(1.286e6, 1.077e6, 0.73)}') | |
print(f'FL: {swing(5.235e6, 5.617e6, 0.91)}') | |
print(f'GA: {swing(1.284e6, 1.620e6, 0.58)}') | |
print(f'IA: {swing(0.465e6, 0.352e6, 0.50)}') | |
print(f'MI: {swing(1.005e6, 1.260e6, 0.43)}') | |
print(f'NC: {swing(2.647e6, 2.721e6, 0.94)}') | |
print(f'OH: {swing(2.245e6, 2.544e6, 0.81)}') | |
print(f'PA: {swing(1.306e6, 1.667e6, 0.45)}') | |
print(f'TX: {swing(4.479e6, 4.855e6, 0.72)}') | |
print(f'WI: {swing(0.868e6, 0.941e6, 0.57)}') |
AZ: (0.38817840554813265, 0.6118215944518673, 329783.7837837839, 519783.7837837839, -189999.99999999994)
FL: (1.3567691601652156, -0.35676916016521565, 301673.4693877548, -79326.53061224519, 380999.99999999994)
GA: (0.6311843711843712, 0.3688156288156288, 654354.430379747, 382354.4303797469, 272000.0000000001)
IA: (0.19262295081967185, 0.8073770491803282, 31333.333333333256, 131333.33333333326, -100000.0)
MI: (0.564635137830002, 0.43536486216999803, 1388981.132075471, 1070981.1320754716, 317999.99999999977)
NC: (0.6090993500464252, 0.39090064995357476, 209361.70212765972, 134361.70212765966, 75000.00000000004)
OH: (1.1605742550367952, -0.16057425503679523, 409361.7021276597, -56638.29787234028, 465999.99999999994)
PA: (0.6102255017931242, 0.3897744982068758, 1652542.3728813562, 1055542.3728813562, 597000.0000000002)
TX: (0.6056011997913406, 0.39439880020865936, 1645886.0759493671, 1071886.0759493671, 574000.0)
WI: (0.570223534373682, 0.429776465626318, 450666.66666666674, 339666.66666666674, 111000.00000000004)
Biden is behind by more votes in Ohio than there are left to be cast. Ohio has been called for Trump.
Biden is behind by more votes in Florida than are left uncounted. But no one has called Florida yet.
#!/usr/bin/env python3
def swing(biden_votes, trump_votes, percentage_counted):
so_far = biden_votes + trump_votes
total = so_far / percentage_counted
remaining = total - so_far
biden_p = 0.5 + (trump_votes - biden_votes) / (2.0 * remaining)
trump_p = 1 - biden_p
return (biden_p, trump_p, biden_p * remaining, trump_p * remaining, (2 * biden_p - 1) * remaining)
print(f'AZ: {swing(1.304e6, 1.114e6, 0.74)}')
print(f'FL: {swing(5.257e6, 5.638e6, 0.98)}')
print(f'GA: {swing(1.814e6, 2.086e6, 0.79)}')
print(f'IA: {swing(0.782e6, 0.682e6, 0.90)}')
print(f'MI: {swing(1.228e6, 1.546e6, 0.53)}')
print(f'NC: {swing(2.655e6, 2.730e6, 0.94)}')
print(f'OH: {swing(2.530e6, 2.996e6, 0.94)}')
print(f'PA: {swing(1.650e6, 2.247e6, 0.59)}')
print(f'TX: {swing(4.825e6, 5.399e6, 0.79)}')
print(f'WI: {swing(1.130e6, 1.241e6, 0.75)}')