This is the given cumulative distribution function:
$F(x) = \begin{cases} 0 & x<0\\ 0.5x & 0≤x<1 \\ 0.25(x-1) + 0.5 & 1≤x<3\\ 1 & y≥3 \end{cases}$
We are asked to determine E($X$), E($X^2$), Var($X$), the mgf of X, and also use the mgf to verify the values of E($X$) and E($X^2$).
I got the following density function from the cdf:
F(x) = \begin{cases} 0 & x<0\\ 0.5 & 0≤x<1 \\ 0.25 & 1≤x<3\\ 0 & y≥3 \end{cases}
My working was:
E($X$)= $\int_0^10.5x\;dx$ + $\int_1^30.25x\;dx$ = $1.25$
E($X^2$)= $\int_0^10.5x^2\;dx$ + $\int_1^30.25x^2\;dx$ = $\frac56$
Mgf = $\int_0^10.5e^{tx}\;dx$ + $\int_1^30.25e^{tx}\;dx$ = $\frac{e^{t}}{4t}+\frac{e^{3t}}{4t}-\frac{1}{2t}$
This seemed a valid cdf, and if so, my questions are: (i) I get a negative value for the variance, so I am not sure if I am calculating E($X$) and E($X^2$) correctly; (ii) the mgf does not seem correct (is it possible to have 't' in the denominator, for example the first derivative of $\frac{1}{2t}$ would be -$\frac{1}{2t^2}$ which would be undefined when we substitute 0 for t).