$$f_{X,Y}(x,y)~=~\begin{cases}2 & if &0< x < 1 ~,~ 0< y< x \\[1ex] 0 & \text{otherwise} \end{cases}$$
Now I should calculate the marginal PDF's.
So I use integral and then I get:
$$f_X(x)~=~\int_{0}^{1}2 ~\mathrm dy~=2$$ $$f_Y(y)~=~\int_{0}^{x}2 ~\mathrm dx~=4$$
I just feel like I'm not doing this correct. So if any of you could help me and tell me what I am doing wrong and how to get the correct answer.
Observe that $$f_{X,Y}=2\mathbf1_{(0,1)}(x)\mathbf1_{(0,x)}(y)$$
For $x\in(0,1)$ we get: $$f_X(x)=\int f_{X,Y}(x,y)dy=\int_0^x2dy=2x$$ For $x\notin(0,1)$ the integrand is $0$ so then $f_X(x)=0$.
For $y\in(0,1)$ we get: $$f_Y(y)=\int f_{X,Y}(x,y)dx=\int_y^12dy=2(1-y)$$ For $y\notin(0,1)$ the integrand is $0$ so then $f_Y(y)=0$.