Suppose you have the following joint density function and marginal densities: image
Apparently, X and Y are independent, since their joint density is the product of their densities. However, I do not understand how this is possible, when the marginal density of X is a function of y.
Thanks in advance
The product you are describing is, in fact, the chain rule: $$ P(X,Y) = P(X \mid Y)P(Y) $$
In this case, we have that the density associated with $Y$ is $f_Y(y) = e^{-y}$ while the density of the conditional distribution $X \mid Y$ is $f_{X \mid Y} = y^{-1} e^{\frac{-x}{y}}$. This tells us that both $X$ and $Y$ are not independent for this joint model, because $P(X,Y) \neq P(X)P(Y)$.