Distribution function of an indicated random variable A random variable $X$ has a distribution function $F$. Let $Y\triangleq XI_{(a,b)}(X)$ with $1<a<b$. Find $G$, the c. d. f. of $Y$.
$$\begin{align}
G(y) &\triangleq \mathbb P(Y\le y) =\\
&= \mathbb P(X\le y)\,I_{(a,b)}(X) + \mathbb P(0\le y)\,I_{(a,b)^\complement}(X) =\\
&= I_{(a,b)}(X)\,F(y) + I_{(a,b)^\complement}(X)\,I_{[0,\infty)}(y)\quad.
\end{align}$$
I'm stuck in the indicators of $X$. It occurred to me to write $I_{(a,b)}(X)$ as $\mathbb P(a<X<b)$, but that's just $E(I_{(a,b)}(X))$. The book gives the answer 
$$\begin{align}
G(y) = [1 - &F(b) + \mathbb P(X=b) - F(a)]\,I_{[0,a)}(y) +\\
&+\; [1 + F(y) - F(b) + \mathbb P(X=b) - 2F(a)]\,I_{[a,b)}(y) + I_{[b,\infty)}(y)\quad.
\end{align}$$
How do I arrive at it?
 A: Think about how you can partition $\mathbb{R}$ such that placing $y$ in different intervals yields different behavior. Notice that $Y$ can either be zero or in the interval $\left(a, b\right)$.


*

*If $y \in \left(-\infty, 0\right)$, then $Y$ cannot possibly be less than or equal to $y$.

*If $y \in \left[0, a\right]$, then $Y$ is less than or equal to $y$ if and only if $X$ is not in $\left(a, b\right)$.

*If $y \in \left(a, b\right)$, then $Y < y$ if $X$ is not in $\left(a, b\right)$ or if $X \in \left(a, y\right]$.

*If $y \in \left[b, \infty\right)$, then $Y$ is certainly less than $y$.


You can create a CDF for each of the above scenarios separately and use indicators for $y$ to choose which one to use depending on which interval $y$ is in. We can use


*

*$G_1(y) = 0$,

*$G_2(y) = 1 - \left[F\left(b\right) - \mathbb{P}\left(X = b\right) - F\left(a\right) \right]$,

*$G_3(y) = \left\{1 - \left[F\left(b\right) - \mathbb{P}\left(X = b\right) - F\left(a\right) \right]\right\} + \left[F\left(y\right) - F(a)\right]$,

*$G_4(y) = 1$,


for the respective situations listed earlier. To be honest this doesn't totally agree with the answer you gave. Instead, I get
$$
\begin{align*}
G\left(y\right)
  &= G_1\left(y\right)I_{\left(-\infty, 0\right)}\left(y\right)
   + G_2\left(y\right)I_{\left[0, a\right]}\left(y\right)
   + G_3\left(y\right)I_{\left(a, b\right)}\left(y\right)
   + G_4\left(y\right)I_{\left[b, \infty\right)}\left(y\right) \\
  &= \left[1 - F\left( b \right) + \mathbb{P}\left(X = b\right) + F\left(a\right) \right] I_{\left[0, a\right]}\left(y\right)  \\
   &\phantom{==}+ \left[1 - F\left(b\right) + \mathbb{P}\left(X = b\right) + F\left(y\right) \right] I_{\left(a, b\right)}\left(y\right) 
   + I_{\left[b, \infty\right)}\left(y\right) 
\end{align*}
$$
Perhaps someone can identify a mistake I've made or confirm that this is correct. I don't believe the solution you posted is correct because $G_3\left(y\right)$ should not depend on $F\left(a\right)$.
