Suppose $X,Y$ are random variables.
Suppose that $(X | Y=y) \sim B(2,e^{-y})$ and that $Y \sim E(1)$.
Find the distribution of $X$.
I'm really struggling with this. Here's what I'm doing:
Let $f_Y(y)=e^{-y}$ be the density of $Y$.
I define $g(Y):=\textbf{P}(X = k | Y = y)$.
Then \begin{align} \textbf{P}(X=k) &= \textbf{E}g(Y) \\ &= \int_0^\infty g(y)f_Y(y) dy \\ &= \int_0^\infty{2 \choose k} e^{-k(y+1)}(1 - e^{-y})^{2-k} dy \\ &= 0 \tag{for k=0,1,2} \end{align}
But this makes no sense at all.
Any advice?
Indeed, that is nonsense. Try this:
$$\begin{align}\mathsf P(X=k) ~&=~ \int_0^\infty\mathsf P(X=k\mid Y=y)\,\mathsf P(Y=y)\operatorname d y\\[1ex] &=~ \int_0^\infty \binom{2}{k}e^{-ky}(1-e^{-y})^{2-k}\cdot e^{-y}~\mathbf 1_{k\in \{0,1,2\}}\operatorname d y\\[1ex] &=~ \int_0^\infty \binom 2ke^{-3y}(e^y-1)^{2-k}~\mathbf 1_{k\in \{0,1,2\}}\operatorname d y \\[1ex] &= \int_0^\infty \left(\begin{cases} e^{-y}-2e^{-2y}+e^{-3y} &:& k=0 \\ 2e^{-2y}-2e^{-3y}&:& k=1\\ e^{-3y} &:& k=2 \\ 0 &:& \text{other}\end{cases}\right)\operatorname d y\\[2ex] &~\vdots\\[2ex] &\neq 0~\mathbf 1_{k\in \{0,1,2\}}\end{align}$$
What it actually equals is quite interesting.