9.1.1 Prior and Posterior
Example
Let $X \sim Uniform(0,1)$. Suppose that we know \begin{align} Y \; | \; X=x \quad \sim \quad Geometric(x). \end{align} Find the posterior density of $X$ given $Y=2$, $f_{X|Y}(x|2)$.
- Solution
- Using Bayes' rule we have \begin{align} f_{X|Y}(x|2)&=\frac{P_{Y|X}(2|x)f_{X}(x)}{P_{Y}(2)}. \end{align} We know $ Y \; | \; X=x \quad \sim \quad Geometric(x)$, so \begin{align} P_{Y|X}(y|x)=x (1-x)^{y-1}, \quad \textrm{ for }y=1,2,\cdots. \end{align} Therefore, \begin{align} P_{Y|X}(2|x)=x (1-x). \end{align} To find $P_{Y}(2)$, we can use the law of total probability \begin{align} P_{Y}(2)&=\int_{-\infty}^{\infty} P_{Y|X}(2|x) f_X(x) \quad \textrm{d}x \\ &=\int_{0}^{1} x (1-x) \cdot 1 \quad \textrm{d}x \\ &=\frac{1}{6}. \end{align} Therefore, we obtain \begin{align} f_{X|Y}(x|2)&=\frac{x (1-x) \cdot 1}{\frac{1}{6}}\\ &= 6x(1-x), \quad \textrm{ for }0 \leq x \leq 1. \end{align}
For the remainder of this chapter, for simplicity, we often write the posterior PDF as \begin{align} f_{X|Y}(x|y)=\frac{f_{Y|X}(y|x)f_{X}(x)}{f_{Y}(y)}, \end{align} which implies that both $X$ and $Y$ are continuous. Nevertheless, we understand that if either $X$ or $Y$ is discrete, we need to replace the PDF by the corresponding PMF.