Let $U$ be uniformly distributed on the interval [$\frac{1}{3},1$]. Let $X$ be a random variable such that the conditional distribution of $X$ given $U = p$ is Geometric with parameter $p$.
Show that $P(X=2) = \frac{2}{3} - \frac{13}{27}$
So this is how I approached the problem:
$P(X=k) = \int_{a}^{b} p(1-p)^{k-1} dx$ since $X$ is distributed geometrically
So then $P(X=2) = \int_{\frac{1}{3}}^{1} p(1-p)^{2-1} dx$
$ = \int_{\frac{1}{3}}^{1} p(1-p)^1 dx = \int_{\frac{1}{3}}^{1} p-p^2 dx$
$ = \frac{p^2}{2}-\frac{p^3}{3} \Big|_{\frac{1}{3}}^1 = \frac{1}{6} - \frac{7}{162}$
and that does not equal what I want so obviously I have messed up somewhere.
I think you just forgot the factor $\frac{3}{2}$; you did not compute the unconditional probability of $X = 2$.
We are told that $X|U\sim\text{Geom}(U)$, and that $U\sim\text{unif}[1/3,1]$. Then \begin{align*} P(X=2)&=\int_{1/3}^3P(X=2|U=u)\cdot f_U(u)\,du\\ &=\int_{1/3}^1(1-u)^{2-1}u\cdot\frac{1}{2/3}\,du \\ &= \frac{3}{2}\left[\frac{u^2}{2}-\frac{u^3}{3}\right]_{1/3}^1 \\ &= \frac{5}{27}. \end{align*}