<s>[INST] Marginal Density - Probability (X,Y) is a two-dimensional abolute continuous random vector with the density function fx,y given by:
(1)
$f_{X,Y}(x,y) = \begin{cases}
\frac{1}{2}  & 0 \le x \le 1, 0 \le y \le 4x \\
0 & \text{otherwise}  \\
\end{cases}$
Show the density functions fx and fy for X and Y are:
$f_{X}(x) = \begin{cases}
2x  & 0 \le x \le 1\\
0 & \text{otherwise}  \\
\end{cases}$
$f_{Y}(y) = \begin{cases}
\frac{1}{2}(1-\frac{y}{4})  & 0 \le y \le 4\\
0 & \text{otherwise}  \\
\end{cases}$

I'm having a hard time figuring out how this works, i have been looking for a while for some similar problems without any luck. 
I can make the step with $$ f_{X}(x) =\int_{0}^{4x} {\frac{1}{2} dy} = 2x$$ 
But $f_{Y}$ i can't figure out and makes me wonder if the first one is done correctly. 
Another example i can't solve is:
(2)
$f_{X,Y}(x,y) = \begin{cases}
\frac{3}{4}x  & 0 \le x \le y \le 2\\
0 & \text{otherwise}  \\
\end{cases}$
$f_{X}(x) = \begin{cases}
\frac{3}{4}x(2-x)  & 0 \le x \le 2\\
0 & \text{otherwise}  \\
\end{cases}$
$f_{Y}(y) = \begin{cases}
\frac{3}{8}y^2  & 0 \le y \le 2\\
0 & \text{otherwise}  \\
\end{cases}$
From what i gathered i should be able to solve it with $\int{f_{X,Y}(x,y)dx}$, but can't seem to do it right. Any help is appreciated.
 [/INST] What you did for $f_{X}$ is OK ! For $f_{Y}$, if you just write $f_{Y}(y) = \int_{0}^{1} \frac{1}{2} \: dx$, you're missing that the condition on $y$ (which is $0 \leq y \leq 4x$) also depends on $x$.
To do this right, use indicator functions. $f_{(X,Y)}$ can be re-written as follows :
$$ f_{(X,Y)}(x,y) = \frac{1}{2} \textbf{1}_{\lbrace 0 \leq x \leq 1 \, ; \, 0 \leq y \leq 4x \rbrace} $$
Which also writes :
$$ f_{(X,Y)}(x,y) = \frac{1}{2} \textbf{1}_{\lbrace 0 \leq x \leq 1 \, ; \, 0 \leq \frac{y}{4} \leq x \rbrace} $$
So, we have :
$$ f_{(X,Y)}(x,y) = \frac{1}{2} \textbf{1}_{\lbrace \frac{y}{4} \leq x \leq 1 \rbrace} $$
Now, let's use our favourite formula : $f_{Y}(y) = \int f_{(X,Y)}(x,y) \: dx$. It leads to the expected result :
$$ f_{Y}(y) =
\begin{cases}
\frac{1}{2} \left( 1 - \frac{y}{4} \right) & \text{if } 0 \leq y \leq 4 \\
0 & \text{otherwise} \\
\end{cases}
$$
</s>