<s>[INST] Find the distribution function for Y for the following density function I am to find the distribution function for Y given the following density function
$$f(y)=\begin{cases}
y,\quad 0<y<1\\
2-y, \quad 1 \leq y < 2\\
0, \quad\text{elsewhere}\\
\end{cases}$$
So since $f(y)$ is given by $\frac{dF(y)}{dy}$, then $F(y)$ should be given by the integral of $f(y)$. So by integrating I get the following:
$$F(y) = \begin{cases}
0, \quad y\leq0 \\
\frac12 y^2,\quad 0<y<1\\
2y-\frac12 y^2, \quad 1 \leq y < 2\\
1, \quad\text{elsewhere}\\
\end{cases}$$
But to be a distribution function $F(y)$ must be continuous for $-\infty < y < \infty$, but my function is not continuous at $y=2$. 
Can someone help me get a continuous distribution function? Thanks.
 [/INST] Let us compute $F(x) = \int_{-\infty}^x f(y)dy$ the distribution function:
If $x<0$ then clearly $F(x)=0$.
If $0<x<1$ then
$$F(x) = \int_{-\infty}^x f(y)dy = \int_{0}^x f(y)dy = \int_0^x ydy = \frac{x^2}{2}.$$
If $1<x<2$ then
$$F(x) = \int_{-\infty}^{x} f(y) dy = \int_0^1 f(y)dy+ \int_1^x (2-y)dy = F(1)+ \bigg(2y - \frac{y^2}{2}\bigg|_{y=1}^{y=x} = \frac{1}{2} + 2x-\frac{x^2}{2} - 2+\frac{1}{2} = 2x-\frac{x^2}{2}-1$$
Remember to subtract the last value here, because you want to compute the accumulated area.
Finally, if $x>2$ then $F(x)=1$. Altogether
$$
F(x)=
\begin{cases} 0, \mbox{ if } x<0 \\
\frac{x^2}{2} \mbox{ if } 0<x<1\\
2x-\frac{x^2}{2}-1 \mbox{ if } 1<x<2\\
1 \mbox{ if } x>2
\end{cases}
$$
</s>