I'm trying to find the mean (expected value) and variance for the following distribution function:
$F(x)=\begin{cases} 0 & \text{for } x \lt 0\\ x/4 & \text{for } 0 \le x \lt 1\\ x^2/4 & \text{for } 1 \le x \lt 2\\ 1 & \text{for } x \ge 2\\ \end{cases}$
First I got the probability density function by differentiating
$f(x)=\begin{cases} 0 & \text{for } x \lt 0\\ 1/4 & \text{for } 0 \le x \lt 1\\ x/2 & \text{for } 1 \le x \lt 2\\ 0 & \text{for } x \ge 2\\ \end{cases}$
Which I simplified as
$f(x)=\begin{cases} 1/4 & \text{for } 0 \le x \lt 1\\ x/2 & \text{for } 1 \le x \lt 2\\ 0 & \text{elsewhere}\\ \end{cases}$
Now I need to find the mean (expected value) and variance. I know that
$E(X)=\int xf(x)\,dx.$
Except I am not sure how I would calculate this as one value due to the function being in multiple parts. Any help is appreciated - Thank You!