<s>[INST] Finding a CDF given a PDF The PDF for $Y$ is
$$f_Y(y) = \begin{cases}
      0 & |y|> 1 \\
      1-|y| & |y|\leq 1
\end{cases}$$
How do I find the corresponding CDF $F_Y(y)$? I integrated the above piecewise function to get
$$F_Y(y)=\begin{cases}
      1/2 -y/2-y^2/2 & [-1,0] \\
      1/2-y/2+y^2/2 & [0,1]
\end{cases}
$$
by using the fact that $F_Y(y)=\int _{-\infty}^{y}{f_Y(y)}\,dy$, however my text claims the answer is 
$$F_Y(y)=\begin{cases}
      1/2 +y+y^2/2 & [-1,0] \\
      1/2+y-y^2/2 & [0,1]
\end{cases}
$$
I am struggling with pdf and cdfs, so I asssume I did something wrong other than the simple integration. Who's correct? Me or the Text!?? $:)$ 
 [/INST] We have that $F(y) = \displaystyle \int_{-\infty}^y f(x) dx$. In your case, we are given that $$f(x) = \begin{cases} 0 & x <-1\\ 1 + x & x \in[-1,0]\\ 1-x & x \in [0,1]\\ 0 & x > 1\end{cases}$$


*

*If $y < -1$, then we have $F(y) = \displaystyle \int_{-\infty}^y f(x) dx = \displaystyle \int_{-\infty}^y 0 dx =0 $. We have the integrand $f(x) = 0$ since $x \leq y < -1$.

*If $y \in [-1,0]$, then we have $F(y) = \displaystyle \int_{-\infty}^y f(x) dx = \displaystyle \int_{-\infty}^{-1} f(x) dx + \displaystyle \int_{-1}^{y} f(x) dx$. Since, $f(x) = 0$ for all $x < -1$, we get that $$F(y) = \displaystyle \int_{-\infty}^y f(x) dx = \displaystyle \int_{-1}^{y} f(x) dx = \displaystyle \int_{-1}^{y} \left( 1+x \right) dx = \left( x + \frac{x^2}{2} \right)_{-1}^{y} $$
$$F(y) = \left(y + \frac{y^2}{2} \right( - \left( -1 + \frac12 \right) = \frac12 + y + \frac{y^2}{2}.$$

*If $y \in [0,1]$, then we have $F(y) = \displaystyle \int_{-\infty}^y f(x) dx = \displaystyle \int_{-\infty}^{-1} f(x) dx + \displaystyle \int_{-1}^{0} f(x) dx + \displaystyle \int_{0}^{y} f(x) dx$. Since, $f(x) = 0$ for all $x < -1$, we get that $$F(y) = \displaystyle \int_{-1}^{0} f(x) dx + \displaystyle \int_{0}^{y} f(x) dx = \displaystyle \int_{-1}^{0} \left( 1+x \right) dx + \displaystyle \int_{0}^{y} (1-x) dx$$
Hence, $$F(y) = \frac12 + \left( x - \frac{x^2}{2}\right)_0^{y} = \frac12 + y - \frac{y^2}{2}$$

*For $y > 1$, since $f(x) = 0$ for all $x>1$, we have that $F(y) = F(1)$ for all $y > 1$. Hence, $F(y) = F(1) = 1$.


Hence, $$F(y) = \begin{cases} 0 & y <-1\\ \frac12 + y + \frac{y^2}{2} & y \in[-1,0]\\ \frac12 + y - \frac{y^2}{2} & y \in[0,1]\\ 1 & y > 1\end{cases}$$
</s>