One generalization of the Bernoulli trials hierarchy is to allow the probability of success probability
to vary across trials. Let $(X_i, P_i)$, $i = 1, \dots, n$ be independent random vectors with
$X_i | P_i \sim \text{Bernoulli}(P_i)$, $i = 1, \dots, n$
$P_i \sim \text{Beta}(\alpha, \beta)$
Consider a random variable of interest $Y = \sum_{i=1}^n X_i$, the total of number of successes.
(a) Show that $E(Y) = n\alpha/(\alpha + \beta)$.
(b) Show that $Var(Y) = n\alpha\beta/(\alpha + \beta)^2$, and hence $Y$ has the same mean and variance as a
$\text{binomial}(n, \alpha/(\alpha + \beta))$ random variable. What is the distribution of $Y$?