Given the PDF $$ f(x) = \begin{cases} 4x, & 0<x< \frac{1}{2} \\ 4-4x, & \frac{1}{2}<x\leqslant1 \\ 0, & \text{otherwise} \end{cases} $$
(A) Determine the cumulative distribution $F(x)$
(B) Determine $P(\frac{1}{3}< X \leqslant \frac{1}{2})$
I don't know how to do this, I know I have to either derive or integrate for A, but I don't know which of the two results to use to find X in B.
(A) The Cumulative Distribution Function (CDF) is defined as $$ F(x)=\int_0^x dy\ f(y)\ . $$ So for $0< x< 1/2$ $$ F(x)=\int_0^x dy\ 4y=2x^2\ , $$ and for $x\geq 1/2$ $$ F(x)=\int_0^{1/2}dy\ 4y+\int_{1/2}^x\ dy(4-4y)=-2 x^2+4 x-1\ . $$ Note that the CDF is right-continuous at $x=1/2$, is increasing and saturates at $1$ as it should.
(B) The probability $P(\frac{1}{3}< X \leqslant \frac{1}{2})$ is obtained by integrating the PDF $f(x)$ between the corresponding bounds $$ P\left(\frac{1}{3}< X \leqslant \frac{1}{2}\right)=\int_{1/3}^{1/2}dx\ f(x)=\int_{1/3}^{1/2}dx\ 4x=\frac{5}{18}\ . $$