An election is being held. There are two candidates, A and B, and there are n voters. The probability of voting for Candidate A varies by city. There are m cities, labeled 1, 2, . . . , m. The jth city has nj voters, so n1 + n2 + · · · + nm = n. Let Xj be the number of people in the jth city who vote for Candidate A, with Xj |pj ∼ Bin(nj , pj ). To reflect our uncertainty about the probability of voting in each city, we treat p1, . . . , pm as r.v.s, with prior distribution asserting that they are i.i.d. Unif(0, 1). Assume that X1, . . . , Xm are independent, both unconditionally and conditional on p1, . . . , pm. Let X be the total number of votes for Candidate A.
(a) Find the marginal distribution of X1 and the posterior distribution of p1|X1 = k1.
(b) Find E(X) and Var(X) in terms of n and s, where s = n1^2 + n2^2 + .... + nm^2.
How do I begin finding the marginal distribution of X1?
Hint for the marginal distribution of $X_1$:
$$\mathbb P(X_1=k_1\mid p_1)={n_1 \choose k_1}p_1^{k_1}(1-p_1)^{n_1-k_1} \text{ for } k_1 \in \{0,1,2,\ldots,n_1\}$$ $$f(p_1)=1\text{ for } 0 \le p_1 \le 1$$ $$\mathbb P(X_1=k_1)= \int_{p_1} \mathbb P(X_1=k_1\mid p_1) f(p_1)\, dp_1$$
The answer should not be a big surprise given that you essentially know nothing about $p_1$