integration and simplification trouble

77 Views Asked by At

I have this function:

$$\pi(\theta|\vec{x}) = \frac{2^{-n/2-2}\theta^{-n/2-3}\left(\sum_\limits{i = 1}^{n} x_i^2+4\right)^{n/2+2}\exp\left({-{\left(\sum_\limits{i = 1}^{n} x_i^2 + 4\right)}/{2\theta}}\right)}{\Gamma(n/2 +2)} $$

and I am trying to take the mean of it with respect to $\theta$.

Here is what I did:

$$E(\theta|\vec{x}) = \int_{0}^{\infty} \theta \, \frac{2^{-n/2-2}\theta^{-n/2-3}\left(\sum_\limits{i = 1}^{n} x_i^2+4\right)^{n/2+2}\exp\left({-{\left(\sum_\limits{i = 1}^{n} x_i^2 + 4\right)}/{2\theta}}\right)}{\Gamma(n/2 +2)} d\theta$$ Using wolfram alpha, the answer came out to be $$=\frac{n (\sum_{i = 1}^{n} x_i^2 + 4)\Gamma(n/2)}{4 \Gamma(n/2+2)}$$

When I simplified this by hand, I got:

$$ = \frac{n (\sum_{i = 1}^{n} x_i^2 + 4)\Gamma(n/2)}{4 (n/2+2)(n/2+1)\Gamma(n/2)} = \frac{n (\sum_{i = 1}^{n} x_i^2 + 4)}{(n+4)(n+2)}$$

However, wolfram showed that the simplification was: $$= \frac{(\sum_{i = 1}^{n} x_i^2 + 4)}{(n+2)}$$ which is not equivalent to the original answer to the integral when plugging numbers in.

Any suggestion on where things might be going wrong would be much appreciated. The answer I obtained from the integral and the hand simplification apparently are not correct.

1

There are 1 best solutions below

0
On BEST ANSWER

Recall that $$\Gamma\left(x+1\right)=x\Gamma\left(x\right)$$

We obtain \begin{align*} \color{blue}{\frac{n\left(\sum_{i=1}^nx_i^2+4\right)\Gamma\left(\frac{n}{2}\right)}{4\Gamma\left(\frac{n}{2}+2\right)}} &=\frac{n\left(\sum_{i=1}^nx_i^2+4\right)\Gamma\left(\frac{n}{2}\right)}{4\left(\frac{n}{2}+1\right)\Gamma\left(\frac{n}{2}+1\right)}\\ &=\frac{n\left(\sum_{i=1}^nx_i^2+4\right)\Gamma\left(\frac{n}{2}\right)}{4\left(\frac{n}{2}+1\right)\left(\frac{n}{2}\right)\Gamma\left(\frac{n}{2}\right)}\\ &\,\,\color{blue}{=\frac{\sum_{i=1}^nx_i^2+4}{n+2}} \end{align*} in accordance with Wolfram Alpha.