Given $f\left(x|\theta\right)=1/\theta, 0\leq x\leq \theta,L\left(\theta, a\right)=\left(a-\theta\right)^2,$ and $\pi\left(\theta\right)=\theta e^{-\theta},\theta\gt 0$
I've seen Problem calculating joint and marginal distribution of two uniform distributions, but it's not what I'm looking for.
Problem: calculate the marginal density of $x$, i.e., $f\left(x\right)$.
\begin{eqnarray} f\left(x\right) &=& \int f\left(x|\theta\right)\pi\left(\theta\right)d\theta\\\ &=& \int \frac{1}{\theta}\cdot\theta\cdot e^{-\theta}d\theta\\\ &=& \int e^{-\theta}d\theta. \end{eqnarray}
Somehow the last equation should turn out to be $e^{-x}$, according to the book. I don't see how this is true, since I'm integrating over $\theta$. I don't understand why $x$ should end up in the solution since it's nowhere in the original equation. I'm also not sure what the limits of integration are. If $\theta > 0$, then I though maybe they should be $\left[0, \infty\right)$, but that gives $1$ as the solution to the integration.