Post Reply 
Election predictions
11-05-2020, 05:03 PM
Post: #1
Election predictions
Given a partial vote count, what percentage of the remaining votes does a candidate need to win the election?

Let:
Rc = percent of counted votes that are for the republican.
Ro = percent of uncounted votes that are for the republican.
Dc = percent votes counted so far that are for the democrat.
Do = percent of uncounted votes that are for the democrat.
N = percent of all votes counted so far.
T = total # votes cast.

A candidate wins if they have slightly more votes than the opponent. So let's set them equal:
Total R votes = Total D votes
Rc*N*T + Ro*(1-N)*T = Dc*N*T + Do*(1-N)*T
(Rc-Dc)N = (Do-Ro)(1-N)
Do-Ro = (Rc-Dc)*N/(1-N)

That gives us the spread. To easily get a real number, let's assume that all outstanding votes are cast for one of these two candidates (Do+Ro = 1):
Do = 1/2 + (Rc-Dc)*N / (2*(1-N))

Or to allow expressing all values as a percent:
Do = 50 + (Rc-Dc)*N / (2*(100-N))
Ro = 50 + (Dc-Rc)*N / (2*(100-N))

Input: Rc [Enter] Dc [Enter] N XEQ A
Output: Do

Example: Trump currently has 49.7% in PA and Biden has 49.1% in Georgia with 95% of the votes counted. What percentage of the remaining votes does Biden need to win?

49.7 [Enter] 49.1 [Enter] 95 XEQ A
Answer: 55.7
So Biden needs 55.7% of the outstanding votes to win Georgia.

Code:
LBL A
Rv
-
R^
*
LastX
100
X<>Y
-
/
2
/
50
+
RTN
Find all posts by this user
Quote this message in a reply
11-05-2020, 08:16 PM
Post: #2
RE: Election predictions
Interesting exercise! However, looking at the Arizona count, with 76.72% of the votes counted, you have

49.43% Biden
48.5% Trump
0.95% Jorgensen (Libertarian)
0.9% None of these candidates
0.21% Don Blankenship (Constitution candidate)

I'd really love to have None of the Above on the ballot.

Headline: "'None of the Above' by a landslide!"

~Mark

Remember kids, "In a democracy, you get the government you deserve."
Find all posts by this user
Quote this message in a reply
11-06-2020, 12:37 AM
Post: #3
RE: Election predictions
(11-05-2020 08:16 PM)mfleming Wrote:  Interesting exercise! However, looking at the Arizona count, with 76.72% of the votes counted, you have [...]

My equation accounts for other candidates in that it checks for how many votes are needed for the two candidates to have an equal number. An earlier version incorrectly computed how much they needed to get 50% of the votes.

However, the program still assumes that the remaining votes will be divided between the two candidates. I could reduce the remaining votes by the same portion of 3rd party votes that are in the counted votes, but I figured that would have a very small effect.

Indeed, it's fun! I keep my Panamatik 34e next to my seat in front of the TV so I can run the program all the time!
Find all posts by this user
Quote this message in a reply
11-06-2020, 11:57 AM
Post: #4
RE: Election predictions
(11-05-2020 05:03 PM)David Hayden Wrote:  Do-Ro = (Rc-Dc)*N/(1-N)

That gives us the spread. To easily get a real number ...

The spread to reach break-even is real enough.

spread = (votes current difference) / (votes remaining)

When spread reached 100%, it is game-over.

Quote:Example: Trump currently has 49.7% in PA and Biden has 49.1% in Georgia with 95% of the votes counted. What percentage of the remaining votes does Biden need to win?

49.7 [Enter] 49.1 [Enter] 95 XEQ A
Answer: 55.7
So Biden needs 55.7% of the outstanding votes to win Georgia.

Did you predicted this ? Big Grin

Just check the tally: 99% counted: Trump = 49.4%, Biden = 49.4%
Find all posts by this user
Quote this message in a reply
11-06-2020, 02:03 PM
Post: #5
RE: Election predictions
(11-06-2020 12:37 AM)David Hayden Wrote:  However, the program still assumes that the remaining votes will be divided between the two candidates. I could reduce the remaining votes by the same portion of 3rd party votes that are in the counted votes, but I figured that would have a very small effect.

The formula with same portion for 3rd party is simple, perhaps simpler.

To break even, total votes for democrats = total votes for republican.
Or, democrats get 50% of votes, shared between the 2 parties.

Dc*N*T + Do*(1-N)*T = (Rc + Dc)/2*T

Do-Dc = (Rc-Dc)/(2*(1-N))

Example, with N=0.95, Rc = 49.7%, Dc = 49.1%:

Do-Dc = 0.6% / 0.1 = 6%

Do = 49.1% + 6% = 55.1%
Find all posts by this user
Quote this message in a reply
11-06-2020, 03:48 PM
Post: #6
RE: Election predictions
These are the formulas I've been using to do quick napkin calculations for catch-up votes required. Probably essentially the same as what everyone else is using.

Inputs

A = Current votes for leading candidate
B = Current votes for trailing candidate
C = Current total votes for other candidates
Vr = Estimated percent of votes reported

Calculations

T: Total votes counted = A+B+C
R: Votes remaining to be counted = T*(1-Vr)/Vr
Vp: Percent of remaining votes needed for trailing candidate to tie = 1-(B+R-A)/(2*R)
Vn: Votes needed for trailing candidate to tie = R*Vp

This assumes that 100% of the outstanding votes will be for either the leading or trailing candidate, which provides a worst-case-scenario estimate for the votes the trailing candidate needs (i.e. playing it safe).

HP 42S version

Code:
LBL "CATCH"
INPUT "A"
INPUT "B"
INPUT "C"
INPUT "VR%"
RCL "A"
RCL+ "B"
RCL+ "C"
1
RCL "VR%"
%
-
LASTX
/
*
ENTER
RCL+ "B"
RCL- "A"
2
/
RCL/ ST Y
1
-
+/-
ENTER
RCL* ST Z
100
STO* ST Z
RDown
END

Input values for A, B, C, and Vr.

Results returned to the stack:

z: R (Votes remaining)
y: Vp (Percent of votes needed by trailing candidate)
x: Vn (Votes needed by trailing candidate)
Visit this user's website Find all posts by this user
Quote this message in a reply
11-06-2020, 07:05 PM (This post was last modified: 11-07-2020 05:19 AM by Gerson W. Barbosa.)
Post: #7
RE: Election predictions
(11-06-2020 12:37 AM)David Hayden Wrote:  Indeed, it's fun! I keep my Panamatik 34e next to my seat in front of the TV so I can run the program all the time!

I was doing something like that manually two (three?) days ago. I didn’t bother to write a program because I didn’t think it would take that long.

That’s what I’ve come up with on the 32SII:

(Edited: This 32SII version is NOT correct. Please refer to the 33s version below)

A01 LBL A
A02 +
A03 R↓
A04 STO T
A05 x⇆y
A06 STO- T
A07 +
A08 100
A09 x⇆y
A10 ×
A11 LASTx
A12 x⇆y
A13 R↑
A14 /
A15 x⇆y
A16 -
A17 RCL+ T
A18 +/-
A19 ENTER
A20 ABS
A21 /
A22 RTN

Example

NEVADA

Biden 626211 49.8%
Trump 605669 48.1%

626211 ENTER
605669 ENTER
49.8 ENTER
48.1
XEQ A
->
-1 (win still uncertain)

——

PS: There’s a mistake here. Instead of 97.8% (49.7 + 48.1) I should use 92 (% of counted votes then). Will fix that later.

——

PSS:

Fixed version:

(on the hp 33s as the ENTER key of my old HP-32SII got stuck)


E0001 LBL E
E0002 +
E0003 100
E0004 ÷
E0005 STO T
E0006 STOP
E0007 ×
E0008 ENTER
E0009 R↓
E0010 R↓
E0011 STO W
E0012 x<>y
E0013 STO- W
E0014 +
E0015 LASTx
E0016 x<>y
E0017 100
E0018 x<>y
E0019 ×
E0020 LASTx
E0021 RCL÷ T
E0022 +/-
E0023 x<>y
E0024 R↑
E0025 ÷
E0026 +
E0027 IP
E0028 ENTER
E0029 RCL+ W
E0030 +/-
E0031 SGN
E0032 RTN

Example

NEVADA

Biden 626211 49.8%
Trump 605669 48.1%
vote count percentage: 92%

626211 ENTER
605669 ENTER
49.8 ENTER
48.1
XEQ E
-> 0.979 [(49.8+48.1)/100]
92 R/S
->
109417 [votes still at stake]
-1 (win still uncertain)


I thought this would be useful again only in 2024, but I see CNN still shows 253x213...
Find all posts by this user
Quote this message in a reply
11-07-2020, 02:20 PM (This post was last modified: 11-07-2020 02:21 PM by Dave Shaffer.)
Post: #8
RE: Election predictions
(11-05-2020 08:16 PM)mfleming Wrote:  I'd really love to have None of the Above on the ballot.

Headline: "'None of the Above' by a landslide!"

~Mark

In Nevada (at least in years past), for local elections, you COULD vote for "none of the above" - it was actually printed on the ballot.

Unfortunately, if (s)he (it?) won, the second place real person was the winner - no do-over.
Find all posts by this user
Quote this message in a reply
11-07-2020, 02:52 PM
Post: #9
RE: Election predictions
In my county, we only had one candidate on the ballot running for re-election for sheriff. He only got about 2/3 of the votes (I didn't fill in that bubble either).
Visit this user's website Find all posts by this user
Quote this message in a reply
11-08-2020, 07:52 PM
Post: #10
RE: Election predictions
(11-05-2020 05:03 PM)David Hayden Wrote:  Example: Trump currently has 49.7% in PA and Biden has 49.1% in Georgia with 95% of the votes counted. What percentage of the remaining votes does Biden need to win?

49.7 [Enter] 49.1 [Enter] 95 XEQ A
Answer: 55.7
So Biden needs 55.7% of the outstanding votes to win Georgia.

Very interesting model and example.

Things have changed quite a bit since this post. I got curious to figure out when a candidate has won a state even though it appears that the candidate has no absolute 100% guarantee to win it, given these numbers.

A 100% guaranteed win requires that all outstanding votes can never contribute to a trailing candidate's win to overtake the current leading candidate. For example, if 1000 votes are outstanding and the difference between the leading and trailing candidate is less than 1000, then the leading candidate has won. But that is too rigid, because the probability (or "odds") of all 1000 remaining uncounted votes to all vote for the trailing candidate is infinitesimal. I suppose we can assume a normal PD for the remaining vote percentages with some given or estimated mean and variance.

Here is my simple model, combined with a statistical estimate for the chance of the leading candidate to win.

L = leading candidate vote percentage
T = trailing candidate vote percentage
V = total votes cast as a percentage
X = minimum vote percentage of the remaining votes for the leading candidate to win

Normalize L, T, V, and X to fractions instead of percentages (just divide by 100), then if

VL + (1-V)X > VT + (1-V)(1-X)

then leading candidate wins, even if 1-X of the votes all go to the trailing candidate. Note that there can be any number of other candidates for this model to work, just think of T to be the closest competitor to L.

Solving for X (the unknown variable), we get:

X > (V(T-L)+R)/(2R)

where R = 1-V.

This is essentially the same as your calculation.

For example, take the state of Nevada. Plugging in the values:
L=.499
T=.479
V=.94
gives
X>.343

Note that there is no 100% guarantee that the leading candidate wins because at least 34.3% of the remaining votes should go the the leading candidate, assuming that in the worst case all other votes go to the competitor. But getting less than 34.3% of the remaining votes seems very unlikely, meaning that winning is likely. But how likely?

I assume the model needs to show at least a 99% probability of winning by the leading candidate for the state to be called, or sufficiently close to 99%.

Assume that the remaining vote distribution is a normal PD with mean .5 (a bit arbitrary but a fair 50% split) and a standard deviation of .1 (10%). The actual values can be determined by sampling the (remaining) votes. In this case we find that p = 0.0116 (e.g. on a calculator plug in these values in the Distribution: Normal PD mode.) The probability for the leading candidate to receive less than the required 34.3% of the remaining votes is sufficiently small, giving about 99% chance of a win. This fits the case for Nevada.

Note that the mean may favor the leading candidate, i.e. a value greater than .5 such as .6 or .7, which means that the variance can be a lot larger than .1 to still reach a 99% certainty of a win.

Disclaimer: this is a fairly simple approach that is not derived from any methods that the statisticians actually apply to make the final call, just a guess. Also, I've made some assumptions that may not be valid. Please do not derive any conclusions and correct me if I'm wrong in your comments and if you have a different method to estimate the probability of an outcome.

"I count on old friends" -- HP 71B,Prime|Ti VOY200,Nspire CXII CAS|Casio fx-CG50...|Sharp PC-G850,E500,2500,1500,14xx,13xx,12xx...
Visit this user's website Find all posts by this user
Quote this message in a reply
11-08-2020, 08:15 PM
Post: #11
RE: Election predictions
(11-08-2020 07:52 PM)robve Wrote:  I assume the model needs to show at least a 99% probability of winning by the leading candidate for the state to be called, or sufficiently close to 99%.

NBC mentioned on the air that they require 99.5% confidence from their models before they officially make any projections/calls. At one point on Friday (I think - the week has been kind of a blur), Chuck mentioned they were above 90% confidence on Biden winning PA, but they weren't officially calling it until they got to 99.5%.

I'm assuming other networks have something similar, though the exact confidence interval and specifics of the models no doubt vary, as not all the networks made the same projections at the same time, despite having the same vote data available. NBC and CNN always seemed to match very closely throughout the week, though. FOX News was something of an outlier with their very early AZ projection; I still don't see any projections for that state from other major news outlets, though I bet you could easily find some analysts and anchors willing to wager money on the outcome.

As for the specifics of the statistical models they're using, I can only assume it's quite a bit more complicated than z-scores on a normal distribution. Smile There's a dizzying amount of variables in play.
Visit this user's website Find all posts by this user
Quote this message in a reply
11-09-2020, 07:53 AM
Post: #12
RE: Election predictions
I noticed that for several days Cnn were reporting "Trump 213", whereas BBC News and Sky News were both reporting "Trump 214".
But I have no idea whether Cnn had some Off-by-one bug analysing the same data, or whether one of those 214 electoral votes was in some way controversial or unconfirmed.

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
11-09-2020, 12:35 PM
Post: #13
RE: Election predictions
(11-09-2020 07:53 AM)StephenG1CMZ Wrote:  I noticed that for several days Cnn were reporting "Trump 213", whereas BBC News and Sky News were both reporting "Trump 214".
But I have no idea whether Cnn had some Off-by-one bug analysing the same data, or whether one of those 214 electoral votes was in some way controversial or unconfirmed.

It was probably one of the states that splits their electoral votes. I saw CNN making a projection on one of those districts pretty late in the game last week.
Visit this user's website Find all posts by this user
Quote this message in a reply
11-09-2020, 06:23 PM
Post: #14
RE: Election predictions
(11-08-2020 08:15 PM)Dave Britten Wrote:  As for the specifics of the statistical models they're using, I can only assume it's quite a bit more complicated than z-scores on a normal distribution. Smile There's a dizzying amount of variables in play.

A more accurate way to determine the confidence in the outcome is to perform Monte Carlo simulations with the remaining votes, each vote is heads or tails with an individual bias/weight (we can ignore all other non-H-T outcomes for now, which does not invalidate the model.) This way we get a weighted sum of random Bernoulli trials. However, that can be very expensive to compute and we may not have sufficient information on the folks who cast the remaining votes to be able to determine the individual weights. If the weights are the same, then the Central Limit Theorem of Bernoulli trials tells us that the sum converges to the normal density function. Hence we can compute our p with a normal PD.

If we assume that all remaining votes are cast by mail, then sampling a portion of the mail-in ballots can tell us the mean and variance of the normal PD of the remaining votes, offering a means to achieve 99.5% confidence in the election prediction.

In (other) elections a multinomial distribution should be used that describes the probabilistic structure of a series of independent and identical Bernoulli trials with constant probabilities and multiple possible outcomes. However, in our case the votes are so close for the two candidates that a normal PD should suffice with only two possible outcomes.

But perhaps multiple distributions can be used to improve the confidence level? For example by splitting the remaining votes into classes of some sort, such as Election Day ballots, mail-in ballots, overseas ballots, etc?

"I count on old friends" -- HP 71B,Prime|Ti VOY200,Nspire CXII CAS|Casio fx-CG50...|Sharp PC-G850,E500,2500,1500,14xx,13xx,12xx...
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)