# Finding the pdf of the posterior distribution and the corresponding Bayes Estimate of $\theta$

Suppose that we observe i.i.d random variables $$X_1, X_2, \ldots , X_n$$ having pmf

$$f_{X}(x\mid\theta) =\theta(1−\theta)^{x−1}I_{\{1,2,3,\ldots\}}(x)$$

where $$\theta\in(0,1)$$. Consider the prior density $$\pi(\theta) =I_{(0,1]}(\theta)$$

(a) Give the pdf of the posterior distribution

(b) Give the Bayes estimate of $$\theta$$ based on the squared-error loss function.

My attempt:

(a)

We have that the posterior-distribution pdf is given by

\begin{align*} \pi(\theta\mid\vec{x}) &=\frac{f(\vec{x}\mid\theta)\cdot\pi(\theta)}{\int_\theta f(\vec{x}\mid\theta)\cdot\pi(\theta) \, d\theta}\\\\ &=\frac{\theta^n(1-\theta)^{\left(\sum X_i\right)-n}I_{(0,1]}(\theta)}{\int_0^1 \theta^n(1-\theta)^{\left(\sum X_i\right)-n} \, d\theta} \end{align*}

I next note that

$$\frac{1}{B\left(n+1,\left(\sum X_i\right)-n+1\right)}\theta^n\left(1-\theta\right)^{(\sum X_i)-n}I_{(0,1]}(\theta) \sim \mathsf{Beta}\left(n+1,\left(\sum X_i\right)-n+1\right)$$

where

\begin{align*} \frac{1}{B\left(n+1,\left(\sum X_i\right)-n+1\right)} &=\frac{\Gamma\left(n+1+\left(\sum X_i\right)-n+1\right)}{\Gamma\left(n+1\right)\Gamma\left(\left(\sum X_i\right)-n+1\right)}\\\\ &=\frac{\Gamma\left(\left(\sum X_i\right)+2\right)}{\Gamma\left(n+1\right)\Gamma\left(\left(\sum X_i\right)-n+1\right)} \end{align*}

so

$$\int_0^1 \theta^n(1-\theta)^{\left(\sum X_i\right)-n} \, d\theta$$

equals

$$\frac{\Gamma(n+1)\Gamma\left(\left(\sum X_i\right)-n+1\right)}{\Gamma\left(\left(\sum X_i\right)+2\right)}\underbrace{\int_0^1 \frac{\Gamma\left(\left(\sum X_i\right)+2\right)}{\Gamma(n+1)\Gamma\left(\left(\sum X_i\right)-n+1\right)}\theta^n(1-\theta)^{(\sum X_i)-n}d\theta}_{=1}$$

Hence the posterior distribution is given by

$$\boxed{\pi(\theta\mid\vec{x})=\frac{\Gamma\left(\left(\sum X_i\right)+2\right)}{\Gamma(n+1)\Gamma\left(\left(\sum X_i\right)-n+1\right)}\theta^n(1-\theta)^{\left(\sum X_i\right)-n} I_{(0,1]}(\theta)}$$

which is the pdf of a beta distribution with $$\alpha=n+1$$ and $$\beta=\left(\sum X_i\right)-n+1$$

with expected value $$\frac{\alpha}{\alpha+\beta}$$. Hence

(b) $$\boxed{\hat{\theta}_B=\frac{n+1}{\left(\sum X_i\right)+2}}$$

Are these valid solutions?