# Calculating marginal distribution via integration

Suppose that we have an IID random sample $\mathbf{x} = (x_1, \dots, x_n)$ from a given distribution with the following PDF:

$$\theta (1 - e^{-x})^{\theta -1}e^{-x}, \, x > 0, \, \theta > 0$$

Also, let's say that we have a non-informative prior distribution such that $\pi(\theta) \propto \frac{1}{\theta^c}$ where $c$ is a given constant. I'd like to calculate the posterior distribution, but to do so, I have to calculate:

$$m(\mathbf{x}) = \int f(\mathbf{x} \mid \theta) \pi(\theta) d\theta = \int_0^{\infty} \left( \prod_{i=1}^n \theta (1-e^{-x_i})^{\theta-1}e^{-x_i} \right)\left(\frac{1}{\theta^c} \right) d \theta$$

I don't see an easy way to integrate the above. The examples I have seen are simple ones such as Poisson with Gamma prior and Binomial with Beta prior. Is there another approach to analytically writing the posterior PDF?

If you consider the change of variable$$y=\exp\{-x\}\,,$$the pdf of $Y$ is given by $$f(x|\theta)=\theta(1-y)^{\theta-1}\,,\quad 0<y<1$$which means you observe [the log-transform of] a $\text{Beta}(1,\theta)$ distribution. The conjugate distributions in that special setting are of the form $θ^a\,b^θ=θ^a\exp\{-\log(b)\theta\}$, hence are the $$\text{Gamma}(\alpha,\beta)\qquad \alpha,\beta>0$$ distributions, with \begin{align*}\pi(\theta|\mathbf{x})&\propto f(\mathbf{x}|\theta)\pi(\theta)\\ &\propto\theta^n\left(\prod_i(1-y_i)\right)^{\theta}\theta^{\alpha-1}e^{-\beta\theta}\\ &= \theta^{\alpha+n-1}\exp\left(-\left[\beta-\sum_i\log(1-y_i)\right]\theta\right)\end{align*} which corresponds to a $$\text{Gamma}(\alpha+n,\beta-\sum_i\log(1-y_i))$$ distribution. The special case $\alpha=-c+1$, $\beta=0$ leads to a $$\text{Gamma}(1-c+n,-\sum_i\log(1-y_i))$$ posterior distribution.
• Can you explain in a bit more detail how one might show that $\mathrm{Beta}(1,\theta)$ has $\mathrm{Gamma}(\alpha,\beta)$ conjugate prior? – PatternMatching Mar 9 '15 at 22:55
• Since the likelihood is of the form $\theta^a\,b^\theta$, this is the functional form of a Gamma distribution. Multiplying by another density of the form $\theta^c\,d^\theta$ keeps the same structure, hence leads to conjugacy. – Xi'an Mar 10 '15 at 9:03
I was not seeing before that you can move product inside the term of the product being exponentiated by $\theta-1$ and that one should focus on which terms depend on $\theta$. You can then plug into Mathematica and it provides the following:
$$e^{-\sum_i x_i} \int_0^{\infty} \theta^n \left( \prod_{i=1}^n (1 - e^{-x_i}) \right)^{\theta-1} \left( \frac{1}{\theta^c} \right) d \theta = e^{-\sum_i x_i}\frac{\Gamma(n + 1 -c) \left(-\log \left( \prod_{i=1}^n(1-e^{-x_i}\right) \right)^{n-c-1}}{\prod_{i=1}^n (1-e^{-x_i})}$$
• You really shouldn't need Mathematica for that. It's some simple manipulation followed by a very short game of 'spot the density' to notice that $\theta$ is in the form of a gamma density; mutliply and divide by the appropriate constant and cross out the integral that's now 1. – Glen_b Mar 8 '15 at 23:02