I am trying to find the marginal distribution f(x) when given the prior distribution $\pi(\theta)$ (Gamma $\alpha, \beta$) and conditional distribution $f(x|\theta)$ (Poisson, $\theta$).
I know the formula to use is either:
${f(x)}=\sum_i{\pi(\theta_i)f(x|\theta_i)}$
or
${f(x)}=\int_\Theta{\pi(\theta)f(x|\theta)} d\theta$
But since the prior is continuous, and the conditional is discrete, I'm not sure which to proceed with (or how to combine them?)
I have assumed to used an integration but not sure about how to proceed after what I have done so far:
f(x) = $\int\frac{\beta^\alpha\theta^{\alpha-1}}{\Gamma(\alpha)}exp(-\beta\theta)\frac{e^{-\theta}\theta^x}{x!}d\theta$
= $\frac{\beta^\alpha}{\Gamma(\alpha)x!}\int\theta^{\alpha-1}e^{-\beta\theta}e^{-\theta}\theta^xd\theta$
Note: The solution is $f(x) = \frac{\beta^\alpha (x+\alpha-1)! }{(\beta+1)^{x+\alpha} \Gamma(\alpha)x!}$ (discrete)
In this case, $X$ is discrete and $\Theta$ is continuous. So whether you regard $f(x|\theta)$ as a function of a discrete random variable depends on whether you are using it as a conditional probability of $X=x$ given the parameter $\Theta=\theta$ or as a likelihood of $\Theta=\theta$ given the observation $X=x$.
Your aggregation of ${\pi(\theta)f(x|\theta)}$ is over $\theta$ so you want the integral.
If you were aggregating over $x$, then you would want the sum, and you should find that $\sum_X f(x)=1$.