# Obtaining PDF of continuous random variable from CDF

I'm trying to study for an exam and I'm having a bit of difficulty understanding the given solution to a particular problem. Given $F_X(x)$ it asks the reader to find $f_X(x)$

$$F_X(x) = \begin{cases} 0 & x < -5 \\ \frac{x+5}{8} & -5\leq x < -3 \\ \frac{1}{4} & -3\leq x < 3 \\ \frac{1}{2} & 3\leq x < 4 \\ \frac{1}{2} + \frac{x-4}{2} & 4\leq x < 5 \\ 1 & x \geq 5 \end{cases} \$$

The provided answer is in terms of the Dirac Delta function $\delta(x)$ and the unit step function $U(x)$

$$f_X(x) = \frac{1}{8}(U(x+5) - U(x+3)) + \frac{1}{4}\delta(x-3) + \frac{1}{2}(U(x-4) - U(x-5)), x \in \mathbb{R}$$

I would appreciate if somebody could give me an explination for this answer. Thank you!

When the CDF of $X$ has a jump at $x_0$, i.e. $F(x_0^-) \neq F(x_0)$, $X$ will take on $x_0$ with probability $F(x_0)-F(x_0^-)$. This can be represented in a density as $(F(x_0) - F(x_0^-)) \delta(x-x_0)$. This is just the fact that the derivative of a step function is a dirac delta, or if you just integrated that term over any set containing $x_0$, it would be $F(x_0) - F(x_0^-)$ (i.e. the probability of getting exactly $x_0$), and zero for any set not containing $x_0$.
If this confuses you, try $F_X(x) = (1-p) U(x) + p U(x-1)$. This is the CDF of a Bernoulli(p) R.V.
Another (easier, I guess) way of looking at it: it's a mixed discrete-continuous rv (I hope this term is not very incorrect). By taking derivatives of $F_X(x)$ you can find that for $-5 \leq x <3 \ f_X(x) = \frac{1}{8}$ and for $4 \leq x <5 \ f_X(x)=\frac{1}{2}$, these two being unit step functions. Also there's a jump at $x=3$ where $f_X(x) = \frac{1}{4}$, this is a Dirac delta function.