# A more general example

• Likelihood: $f\left(\left.x\right|p\right)=p^{x}\left(1-p\right)^{1-x}1\left(x\in\left\{ 0,1\right\} \right)$, before.
• Prior Belief: $f\left(p\right)=Beta\left(\alpha,\beta\right)=\frac{\Gamma\left(\alpha+\beta\right)}{\Gamma\left(\alpha\right)\Gamma\left(\beta\right)}p^{\alpha-1}\left(1-p\right)^{\beta-1}$. (note that $Beta\left(1,1\right)=U\left(0,1\right).$)

Recall that $E\left(p\right)=\frac{\alpha}{\alpha+\beta}$ and $Var\left(p\right)=\frac{\alpha\beta}{\left(\alpha+\beta\right)^{2}\left(1+\alpha+\beta\right)}$.

The posterior probability when $x=1$ is given by:

$f\left(\left.p\right|x=1\right)=\frac{\frac{\Gamma\left(\alpha+\beta\right)}{\Gamma\left(\alpha\right)\Gamma\left(\beta\right)}p^{\alpha-1}\left(1-p\right)^{\beta-1}p}{f_{X}\left(1\right)=\int_{0}^{1}f_{\left.X\right|p}f_{p}dp}$

Notice that $f_{X}\left(x\right)$ does not depend on the random variable of $f\left(\left.p\right|x=1\right)$, which is $p$. In fact, the denominator is only required to ensure that $f\left(\left.p\right|x=1\right)$ integrates to one.

The implication is that we can ignore the denominator and focus on the part that does depend on $p$, the kernel of $f_{\left.p\right|X}$. We end up with the following identity:

$f\left(\left.p\right|X\right)\propto p^{\alpha}\left(1-p\right)^{\beta-1}$

where $\propto$ can be read as “is proportional to”, and $p^{\alpha}\left(1-p\right)^{\beta-1}$ is the kernel.

Inspection of the Kernel implies that $f\left(\left.p\right|x=1\right)$ is a Beta distribution with parameters $\alpha+1$ and $\beta$.

The mean and variance of $\left.p\right|x=1$ are given by

\begin{aligned} E\left(\left.p\right|x=1\right) & =\frac{\alpha+1}{\alpha+\beta+1}.\\ Var\left(\left.p\right|x=1\right) & =\frac{\left(\alpha+1\right)\beta}{\left(\alpha+\beta+1\right)^{2}\left(\alpha+\beta+2\right)}.\end{aligned}

It is often easy to identify the distribution by its kernel. In our example, it is clear that

$f_{X}\left(1\right)=\frac{\Gamma\left(\alpha+\beta\right)}{\Gamma\left(\alpha\right)\Gamma\left(\beta\right)}.\frac{\Gamma\left(\alpha+1\right)\Gamma\left(\beta\right)}{\Gamma\left(\alpha+\beta+1\right)}=\frac{\alpha}{\alpha+\beta},$

so that we end up with a Beta distribution that integrates to one.