Ballot Sampling with Bayes¶
Beta Binomial¶
Beta-Binomial Distribution
A random variable \(X\) has a Beta-Binomial distribution, \(X \sim \mathrm{BetaBin} (n,\alpha ,\beta)\) iff
for \(x \in \lbrace 1,...,n \rbrace\).
Remark
Note that \(f(x|n,\alpha ,\beta) \propto \frac{1}{x! (n-x)!} \Gamma(x+\alpha) \Gamma(n-x + \beta)\) when we consider \(x\) to be the only variable.
This distribution can be derived from a binomial likelihood with a beta distributed prior \(\theta=\mathbb{P}(\text{success})\).
Hypergeometric Distribution¶
Hypergeometric Distribution
Suppose there are \(N\) balls, \(X\) of the balls are red. Suppose we sample \(M\) balls without replacement. Let \(Y\) denote the number of red balls in the sample. Then,
Proof
As a result of the multiplication principle. The number of combinations that contain y red balls is \({X \choose y} \times {N-X \choose M-y}\).
Conjugate Prior¶
Hypergeometric Conjugate Prior
Suppose there are \(N\) ballots and we sample \(M \in \lbrace 1, ..., N \rbrace\). Let the random variable \(X\) be the total number of Labour ballots. Let \(Y\) be the number of Labour ballots in the sample.
If we place the following prior on \(X\),
then likelihood of \(Y\) given \(X\) is hypergeometric and the posterior distribution of \(X\) is given by
Proof
Notice that if we consider \(x\) the only variable,
The posterior calculation then gives a multiple of this when \(x\) is the only variable,
Reference other file here.