Let $M$ be a number randomly selected from $[-1,4]$. Find the density function of $N=|2M+1|$.
My Attempt: I'll use the method of distribution functions.
First I note that
$(i)$ $N = -2X-1 : X \in[-1,\frac{-1}{2}) \Rightarrow Y \in (0,1]$
$(ii)$ $N= 2X+1 : X \in [\frac{-1}{2},4] \Rightarrow Y \in [0,9]$
So for $(i)$:
$F_Y(y) = P(Y \le y) = P(-2X-1 \le y) = P(x \le \frac{y+1}{-2}) = F_X(\frac{y+1}{-2})$
Since $X$ is a uniform continuous random variable we have that $F_X(x) = \frac{x-a}{b-a} for x\in[a,b]$. Thus,
$F_X(\frac{y+1}{-2}) = \frac{\frac{y+1}{-2} - (-1)}{\frac{-1}{2}-(-1)} = -y-1$
Thus, $F_Y(y) = -y-1 \Rightarrow f_y(y) = F_Y^{'}(y)=-1$
$\Rightarrow f_y(y) = -1, y\in (0,1]$
By similiar methods for $(ii)$:
$F_Y(y) = P(x \le \frac{y-1}{2}) = F_X(\frac{y-1}{2}) = \frac{y}{9} \Rightarrow f_y(y) = \frac{1}{9}, y \in[0,9]$
Combining these together I get that $f_y(y) = -1+ \frac{1}{9}, y \in (0,1], \frac{1}{9}, y \in (1,9] \cup \{0\}$
But this isn't a proper probability density function because the integral from $-\infty$ to $+ \infty$ is not equal to $1$.
Lets have a nice go at this together. We shall do this in two steps. Firstly let $Y = |2M+1|$
$\textbf{Step 1:}$
The cumaltive density of $Y:$$ F_Y(x) := \mathbb{P}(Y\leq x) = \mathbb{P}(|2M+1| \leq x) = \mathbb{P}( -x\leq2M+1\leq x)=\mathbb{P}(-x-1\leq 2M \leq x -1) =\mathbb{P}(\frac{-(x+1)}{2} \leq M \leq \frac{x-1}{2} ) = \mathbb{P}(M \leq \frac{x-1}{2}) - \mathbb{P}(M \leq \frac{-(x+1)}{2})$
This might get quite fiddly with all the different ranges. Firstly it's wise to note that $M$ ranges from $-1$ to $4$ and hence if $m\in[-1,4]$ then $\mathbb{P}(M \leq m ) = \frac{m+1}{5}$ if $m \geq 4 $ then $\mathbb{P}(M \leq m ) =1 $ and if $m \leq -1 $ then $\mathbb{P}(M \leq m ) = 0 $
Let us first deal with evaluating $\mathbb{P}(M \leq \frac{x-1}{2})$
Firstly $\frac{x-1}{2} \geq 4 \iff x \geq 9 $ and $\frac{x-1}{2} \leq -1 \iff x \leq -1$ Hence for $x\in[-1,9]$ $ \mathbb{P}(M \leq \frac{x-1}{2}) = \frac{\frac{x-1}{2}+1}{5} = \frac{x+1}{10}$
And for $x$ less than $-1$ or greater than $9$ the probability for $M$ to be less than $\frac{x-1}{2}$ is respectively $0$ and $1$
Complete $\mathbb{P}(M \leq \frac{-(x+1)}{2})$ the exact same way and then differentiate for the density.