# Marginal pdf from conditional pdf

Let the conditional pdf of $$X$$,given $$Y=y$$ be given by $$f(x|y)=e^{y-x} , x>y$$

and let $$Y$$ have the pdf $$g(y)=\lambda{e^{-\lambda y}},y>0,\lambda>0,\lambda \neq 1$$ We need to find the marginal pdf of $$X$$.

Of course $$f_{X}(x)=\int_{0}^{x}f(x|y)g(y) dy= \int_{0}^{x} \lambda e^{(1-\lambda)y-x} dy= \frac{\lambda}{1-\lambda} e^{-x}(e^{x-\lambda x}-1)$$. Am I correct?

Observe that in general for two random variables $$X$$ and $$Y$$ $$$$p(X) = \int p(X,Y) dY = \int p(Y|X)p(X)dY = \int p(X|Y) p(Y) dY$$$$