# Voting: probability of outcome flip

Assume you have a set of $N$ persons who should vote in a poll "for" or "against" an issue. The outcome of the poll is taken with simple majority.

Each person's vote is independent of the rest and has a probability $p$ of voting "for" and $1-p$ of voting against. The value of $p$ is the same for every voter.

Assume now that $n<N$ persons have already voted and $N-n$ are still to vote. You know their $n$ votes, and the partial poll outcome is "for", with a ratio of $r = n_{for}/n > 0.5$. You don't know, however, the true value of $p$.

The question is, which is the probability that the outcome of the poll will change to "against" with the remaining $N-n$ votes?

So far I only have intuitions like:

• The probability should be lower the larger is $n$
• The probability should be lower the farther is $r$ from $0.5$
• The probability is zero once $n_{for} > N/2$

But I need an expression for that probability... Any ideas?, I have ran out of them for sure...

Consider the probability of getting $n_{for}$ votes out of $n$ observations with our base assumption of independence. For a given $p$ the probability of such an observation is:

$P(p)=$$\frac{\Gamma (n+2)}{\Gamma (n_{for}+1) \Gamma (n-n_{for}+1)}$$p^{n_{for}}(1-p)^{n-n_{for}}$

We then proceed to calculate the probability by summing over all possible states. As you guessed there is an edge case where we have $n_{for}>N/2$ or $n-n_{for}>N/2$ where our vote is already decided. If we aren't in such a case we can evaluate the sum/integral:

$\sum_{i=Ceiling(N/2)-n_{for}} ^{N-n} \int_0 ^1 dp (P(p) \binom{N-n}{i} (p)^i (1-p)^{N-n-i})$

Evaluating the integral yields:

$\sum_{i=Ceiling(N/2)-n_{for}} ^{N-n} \frac{\Gamma (n+2) \Gamma (i+n_{for}+1) \Gamma (N-n+1) \Gamma (-i+N-n_{for}+1)}{\Gamma (i+1) \Gamma (N+2) \Gamma (n_{for}+1) \Gamma (n-n_{for}+1) \Gamma (-i+N-n+1)}$

And finally using a computer I was able to get the following expression:

$\frac{\pi \Gamma (n+2) \Gamma \left(\left\lceil \frac{N}{2}\right\rceil +1\right) \Gamma (N-n+1) \, _3\tilde{F}_2\left(1,\left\lceil \frac{N}{2}\right\rceil +1,-N+n-n_{for}+\left\lceil \frac{N}{2}\right\rceil ;\left\lceil \frac{N}{2}\right\rceil -N,-n_{for}+\left\lceil \frac{N}{2}\right\rceil +1;1\right)}{\Gamma (N+2) \Gamma (n_{for}+1) \Gamma (n-n_{for}+1) \Gamma \left(N-n+n_{for}-\left\lceil \frac{N}{2}\right\rceil +1\right)}$

where $\tilde{F}$ is the regularized generalized hypergeometric function.

This would be the probability of not switching so subtract the above from 1 to get the probability of switching.

If we know p ahead of time then this is actually a trivial problem:

$\sum_{i=ceiling{N/2}-n_{for}} ^{N-n} p^i (1-p)^{N-n-i} \binom{N-n}{i} =$ $p^{\left\lceil \frac{N}{2}\right\rceil - n_{for}} \binom{N-n}{\left\lceil \frac{N}{2}\right\rceil -n_{for}} (1-p)^{-\left\lceil \frac{N}{2}\right\rceil +N-n+n_{for}} \, _2F_1\left(1,-N+n-n_{for}+\left\lceil \frac{N}{2}\right\rceil ;-n_{for}+\left\lceil \frac{N}{2}\right\rceil +1;\frac{p}{p-1}\right)$

• Nice work, but isn't this the marginal probability of switching? I interpreted the question as conditional on $N-n$ and $n_\text{for}$.. Commented May 18, 2016 at 2:51
• I suppose I made a leap by integrating out $p$.(this is what you are getting at right?) I was more or less looking at it as "you observe $n_{for}$ out of $n$ now what's the probability that the vote will flip in the next $N-n$ as a function of these parameters". I can add in the function of $p$ part. Commented May 18, 2016 at 3:07
• Right, but as far as I can tell that should just be a straightforward binomial $Pr(\text{switch}) = F(\frac{N}{2} - n_\text{for}; p)$ Commented May 18, 2016 at 4:05
• But that's boring ;) Commented May 18, 2016 at 4:06
• I think you interpreted correctly @Kitter. The key problem is that I don't know $p$, but can estimate it based on the current set of votes. Having said that, I will try to understand your answer and see if I can implement it. Commented May 18, 2016 at 6:06

I don't know what you mean by switching. It could be the against side leading at some point during the count or the against side winning overall. This is for against winning overall.

Just assume the remaining votes are binomial and the for side has a head start.

$P(k > \frac{N}{2} - n_{against}|N-n,p)$

Case study:

1,000,000

Pre-poll
We need 450,000+ against votes on polling day for the against side to win overall. I'm assuming that $n_{for}$ is known and that the pre-poll numbers don't affect our inference on $p$.
• Thanks for the answer. I believe it assumes I know $p$, but I don't, I just have $r$ as an estimation of it, but it can be wrong. Commented May 18, 2016 at 5:59
• I guess the correct approach would then be to have a prior on $p$, which has been updated by the pre-poll to give you a posterior for $p$. You would then integrate out $p$ i.e. $P(k > \frac{N}{2} - n_{against} | N - n) = \int_0^1 P(k > \frac{N}{2} - n_{against} | N - n, p) P(p|r,n) dp$ Commented May 19, 2016 at 1:07