I'm stuck with this problem. I've done something, but I'm not sure if I'm correct or not. Suppose $X$ is a r.v that has a uniform distribution over the interval $[-2,2]$. What is $F_Y(y)$ and $f_Y(y)$ if $Y =g(X)$ where $g$ is a piecewise linear function defined by $$g(x) = \left\{ \begin{array}{ll} -1&\text{if} &x < -1 \\ x & \text{if}&-1\leq x\leq 1 \\ 1&\text{if}&x>1 \\ \end{array} \right. $$
Here's what I've done so far. $$Y = g(X) = \left\{ \begin{array}{ll} -1&\text{if} &X < -1 \\ X & \text{if}&-1\leq x\leq 1 \\ 1&\text{if}&X>1 \\ \end{array}\right. $$
Therefore, we can say that the range of $Y$ is: $R_{Y} = [-1,1]$, which means that $F_{y}(y) = 0$ for all $y<-1$ and $F_{Y}(y) = 1$ for all $y>1$
Then, I computed $P(Y=-1)$ and $P(Y=1)$. I got the following: $$P(Y=-1)\\ = P(g(X) = -1) \\ =P(-2<X<-1) + P(X=-1) \\=P(-2<X<1) \\ = \frac{1}{4}$$
We get the same result for $P(Y = 1)$.
Now, let $y \in ]-1,1[$, then we have that $P(-1<Y<1) = P(-1<X<-1) = \frac{1}{2}$
So, assuming I didn't make any mistake so far, I would say that$$F_{Y}(y) = \left\{ \begin{array}{ll} \frac{1}{4}&\text{if} &y= -1 \\ \frac{1}{2} & \text{if}&-1\leq y\leq 1 \\ \frac{1}{4}&\text{if}&y=1 \\ \end{array} \right. $$
Now, I don't exactly know how to get the probability density function. The answer sheet says the following:
$f_Y(y) = 0$ for $|y| > 1$, $f_Y(y) = 1/4$ for $|y| < 1$ and $f_Y(y) = \delta(|y|-1)/4$, where $\delta(x)$ is the dirac function (i.e. $\delta(x)= \left\{ \begin{array}{ll} \infty&\text{if} &x= 0 \\ 0 & \text{if}& x\neq 0 \end{array} \right.$)
The answer sheet doesn't say anything about $F_Y(y)$ and I have no idea how I am supposed to find $f_Y(y)$ from $F_Y(y)$
Everything you wrote until your definition $F_Y$ is correct. Recall that:
$$F_Y(y)=\mathbb{P}[Y\le y]$$
So if $-1<y<1$:
$$F_Y(y)=\mathbb{P}[g(X)\le y]=\mathbb{P}[-2\le X\le y]=\frac{y+2}{4}$$
Providing that it makes sense for you to consider probability density functions with infinite values, you can get $f_Y$ from $F_Y$ by differentiating:
$$f_Y(y)=F_Y'(y)=\left\{ \begin{array}{ll} 0& \text{if}& |y|>1\\ \infty& \text{if}& |y|=1\\ 1/4& \text{if}& |y|<1\\ \end{array} \right. $$