Computing a marginal posterior of a hierarchical model This is my first time posting an actual homework question. Usually I have more local resources such as office hours and student peers but this time I am a little short on those. I also need to rest but I can't so I'm spinning my wheels a lot more than I ordinarily would.
I have a hierarchical model of $m$ different binomials with $m$ different sample sizes, whose $m$ different $p$ parameters are governed by a population beta distribution. The beta distribution, of course, also has a prior.
I constructed what I think is the correct joint posterior distribution for this model:
$$P(p_1, p_2,\dots,p_{m}, \alpha,\beta|\mathbf X)\propto \pi(\alpha, \beta)\prod_{i=1}^{m} P(p_i|\alpha, \beta)P(x_i|p_i)$$
$$\propto\pi(\alpha, \beta) \prod_{i=1}^{m}p_i^{x_i+\alpha-1}(1-p_i)^{n_i-x_i+\beta-1} $$
The problem I am facing is that if I want to compute
$$P(\alpha,\beta|\mathbf X)$$
It seems as though, since I have m parameters to remove I am looking at m integrals (integrals because the beta is continuous). 
This can't possibly be what I am expected to do unless one of the following is true:


*

*I got the joint posterior incorrect

*I should be doing this by sampling

*There is an easier trick to mathematically computing a marginal posterior on this

*I have the wrong idea of what marginalizing m parameters from a population distribution
amounts to (eg. we just integrate once since they are all from the same distribution; I can't see what to make of the individual p parameters in that case) 
 A: I was correct in assuming that there was a trick. Here is the given solution:
The trick is that each $p_i$ is independent so you can rewrite the problem as the joint product of m individual integrals.
More specifically with $c=\frac{1}{B(\alpha, \beta)}$,
$$P(\alpha,\beta|\mathbf X)=\int_{p_1}\dots\int_{p_m}\pi(\alpha, \beta) \hspace{2mm} c^m\hspace{2mm} p_i^{x_i+\alpha-1}(1-p_i)^{n_i-x_i+\beta-1} dp_{1}\dots dp_{m}\\= \pi(\alpha, \beta) \hspace{2mm}c^{m} \prod_{i=1}^{m}\int_{p_i}p_i^{x_i+\alpha-1}(1-p_i)^{n_i-x_i+\beta-1}dp_i$$ 
Because this is the kernel of a $Beta(\alpha + x_i, \beta + n_i-x_i)$  we know each one will integrate to 1 if we add the necessary constant term.
$$\pi(\alpha, \beta) \hspace{2mm}c^{m} \prod_{i=1}^{m}B(\alpha + x_i, \beta + n_i-x_i)* \\ \int_{p_i}B(\alpha + x_i, \beta + n_i-x_i)^{-1} p_i^{x_i+\alpha-1}(1-p_i)^{n_i-x_i+\beta-1}dp_i\\=\pi(\alpha, \beta) \hspace{2mm}c^{m} \prod_{i=1}^{m}B(\alpha + x_i, \beta + n_i-x_i)$$
with $c=\frac{1}{B(\alpha, \beta)}$ the full expression is
$$P(\alpha,\beta|\mathbf X)=\pi(\alpha, \beta) \hspace{2mm}B(\alpha, \beta)^{-m} \prod_{i=1}^{m}B(\alpha + x_i, \beta + n_i-x_i)$$
In the problem I recieved it wasn't stated that the $p_i$ were independent but the original problem was counting bicycles amongst all traffic on different blocks so I suppose it is a logical assumption.
