# how to get posterior distribution of beta with gamma prior

I have

$X_1, ..., X_n \sim beta(\theta,1)$ and $\theta \sim gamma(r, \lambda)$ and wish to compute the posterior distribution.

Since $f(\textbf{X} | \theta) = \theta^nx^{n(\theta-1)}$ and $\pi(\theta) = \frac{1}{\Gamma(r)\lambda^r}\theta^{r-1}e^{-\theta/\lambda}$, we get $f(\textbf{X} | \theta) \pi(\theta) = \theta^nx^{n(\theta-1)}\frac{1}{\Gamma(r)\lambda^r}\theta^{r-1}e^{-\theta/\lambda} = \frac{1}{\Gamma(r)\lambda^r}x^{n(\theta-1)}\theta^{n+r-1}e^{-\theta/\lambda}$

But I'm having trouble computing the marginal which is $$\int_0^\infty f(\textbf{X}|\theta)\pi(\theta)d\theta =\frac{1}{\Gamma(r)\lambda^r}\int_0^\infty x^{n(\theta-1)}\theta^{n+r-1}e^{-\theta/\lambda} d\theta$$

How do I do this integration? Is there a way I can conclude that posterior is gamma without doing the integration?

• Why are you using a gamma distribution for a prior?
– Jon
Jun 2, 2018 at 15:33
• Also, how are you getting $f(x|\theta)$? $Beta(\theta, 1) \propto (x - 1)^{\theta-1} \times (1 - x)^{1-1} = (x - 1)^{\theta-1}$
– Jon
Jun 2, 2018 at 15:37
• I think it's $x^{\theta-1}$ not $(x-1)^{\theta-1}$ Jun 3, 2018 at 1:16
• You are correct, $Beta(\theta, 1) \propto x^{\theta-1}$ so where do you get $\theta^n$ from? (the $n$ I follow, but not $\theta$)
– Jon
Jun 4, 2018 at 15:50

You don't really have to do the integration!

Here's a detailed derivation.

Denote the pdf of the posterior distribution as $$\pi(\theta|\textbf{X})$$ and the marginal pdf of $$\textbf{X}$$ as $$m(\textbf{X})$$.

$$\pi(\theta|\textbf{X}) = \frac{f(\textbf{X}|\theta)\pi(\theta)}{m(\textbf{X})}$$

\begin{aligned} m(\textbf{X}) &= \int_0^\infty f(\textbf{X}|\theta)\pi(\theta) d\theta \\ &= \int_0^\infty \left[\theta^n\prod_i^nx_i^{\theta-1}\right] \frac{1}{\Gamma(r) \lambda^r} \theta^{r-1}e^{-\frac{\theta}{\lambda}} d\theta \\ &= \int_0^\infty \theta^n e^{{(\theta-1)}\sum_i^n \log x_i} \frac{1}{\Gamma(r) \lambda^r} \theta^{r-1}e^{-\frac{\theta}{\lambda}} d\theta \\ &= \frac{1}{\Gamma(r) \lambda^r} e^{-\sum_i^n \log x_i} \int_0^\infty \theta^{r + n - 1} e^{{-\theta}\left( \frac{1}{\lambda} -\sum_i^n \log x_i\right)} d\theta \\ &=\frac{1}{\Gamma(r) \lambda^r} e^{-\sum_i^n \log x_i} \int_0^\infty \theta^{r + n - 1} e^{\frac{-\theta}{\lambda_*}} d\theta \hspace{0.5cm}, \hspace{1cm} where \hspace{0.5cm} \lambda_* = \frac{1}{\left( \frac{1}{\lambda} -\sum_i^n \log x_i\right)} > 0\\ &= \frac{1}{\Gamma(r) \lambda^r} e^{-\sum_i^n \log x_i} \left[\Gamma(r+n)\right] \lambda_*^{r+n} \int_0^\infty \frac{1}{\left[\Gamma(r+n)\right] \lambda_*^{r+n}} \theta^{r + n - 1} e^{\frac{-\theta}{\lambda_*}} d\theta \\ &=\frac{1}{\Gamma(r) \lambda^r} e^{-\sum_i^n \log x_i} \left[\Gamma(r+n)\right] \lambda_*^{r+n} \end{aligned}

You also have that:

$$f(\textbf{X}|\theta)\pi(\theta) = \frac{1}{\Gamma(r) \lambda^r} e^{-\sum_i^n \log x_i} \theta^{r + n - 1} e^{\frac{-\theta}{\lambda_*}}$$

Now take the ratio and you will get:

$$\pi(\theta|\textbf{X}) = \frac{1}{\left[\Gamma(r+n)\right] \lambda_*^{r+n}}\theta^{r + n - 1} e^{\frac{-\theta}{\lambda_*}} 1_{(0, \infty)}(\theta) \thicksim Gamma(r+n, \lambda_*)$$