Variance of mixed random variable $X \sim F(x)$
$$F(x)=\begin{cases}0,&x<0\\x^2,&0\leq x<1/2\\x,&1/2\leq x<1\\1,&x>1\end{cases}$$
(not right-continuous)
I want to compute $\operatorname{Var}(X)$.
Is this correct:
$$\mathbb E[X]=\int_0^{1/2}2x^2\,dx+\int_{1/2}^1x\,dx+1/2\cdot \mathbb P(1/2)$$
How can I evaluate $\mathbb P(X=1/2)$? Is it $1/2 -(1/2)^2$?
And how do I evaluate $\mathbb E[X^2]$?
$$Y:=X^2$$
$$F_Y(x)=\mathbb P[Y \leq x]=\mathbb P[X^2 \leq x]=\mathbb P[X \leq \sqrt x]=F(\sqrt x)=\begin{cases}0,&x<0\\x,&0\leq x<1/4\\\sqrt x,&1/4\leq x<1\\1,&x>1\end{cases}$$
$$\mathbb E[X^2]=\int_0^{1/2}2x^3\,dx+\int_{1/2}^1x^2\,dx+1/4\cdot \mathbb P(1/4)$$
$$\mathbb P(X=1/4)=\sqrt{1/4} -1/4?$$
 A: the variance should be $$\operatorname{Var}(X)=\mathbb E[(X-\mathbb E[X])^2] = \mathbb E[X^2]-\mathbb E[X]^2$$
$$\mathbb E[g(x)]=\int g(x) f(x) \, dx$$
where $f(x)$ is the probability distribution function (pdf)
$$f(x)=\frac{dF(x)}{dx}=\frac{1}{4}\delta(x-\frac{1}{2})+\begin{cases}0,&x<0\\2x,&0\leq x<1/2\\1,&1/2\leq x<1\\0,&x>1\end{cases}$$
where $\delta (x)$ is the Dirac delta function
$$\mathbb E[X]=\int_0^{1/2}2x^2 dx+\int_{1/2}^1x \, dx+\frac{1}{4}\int \delta(x-\frac{1}{2})x \, dx$$
$$=\frac{2}{3}\left(\frac{1}{2}\right)^3+\frac{1}{2}\left(1-\frac{1}{4}\right)+\frac{1}{4}\left(\frac{1}{2}\right)=\frac{7}{12}$$
$$\mathbb E[X^2]=\int_0^{1/2}2x^3\ dx+\int_{1/2}^1x^2\ dx+ \frac{1}{4}\int \delta(x-\frac{1}{2})x^2dx$$
$$=\frac{2}{4}\left(\frac{1}{2}\right)^4+\frac{1}{3}\left(1-\frac{1}{8}\right)+\frac{1}{4}\left(\frac{1}{4}\right)=\frac{296}{768}$$
$$\mathbb E[X^2]-\mathbb E[X]^2 = 296/768-49/144 = 13/288$$
A: Your expression for $\ \mathbb{E}\left[X\right]\ $ is correct if $\ \mathbb{P}\left(\frac{1}{2}\right)\ $ is taken to mean the same thing as $\ \mathbb{P}\left(X=\frac{1}{2}\right)\ $. And yes, the value of $\ \mathbb{P}\left(X=\frac{1}{2}\right)\ $ is the size of the jump in $\ F\ $ at $\ x=\frac{1}{2}\ $:
$$
\mathbb{P}\left(X=\frac{1}{2}\right)=F \left(\frac{1}{2}\right)-\lim_{x\rightarrow\left(\frac{1}{2}\right)^-}F(x)= \frac{1}{2}-\frac{1}{4}\ .
$$
There's a problem, however with your formula for $\ \mathbb{E}\left[X^{\color{red}2}\right]\ $ (even apart from the typo flagged by the red superscript in the preceding expression, which is missing from the expression on the left side of your equation).  You appear to have used something like the identity
\begin{align}
\mathbb{E}\left[X^2\right]&=\int_{-\infty}^\infty x^2dF(x)\\
&=\int_0^\frac{1}{2}x^2F'(x)dx +\left(\frac{1}{2}\right)^2\mathbb{P}\left(X=\frac{1}{2}\right)\\
&\hspace{1.5em}+ \int_ \frac{1}{2}^0x^2F'(x)dx\\
&= \int_0^\frac{1}{2}2x^3dx+ \left(\frac{1}{2}\right)^2\mathbb{P}\left(X=\frac{1}{2}\right)+\int_\frac{1}{2}^1x^2dx\ ,
\end{align}
which would have been correct, but in place of $\ \mathbb{P}\left(X=\frac{1}{2}\right)\ $ you have $\ \mathbb{P}\left(\frac{1}{4}\right)\ $.  Was this another typo?
Also, your derivation of the distribution of $\ Y=X^2\ $ is a little puzzling. While the derivation is correct, and this distribution could have been used to compute $\ \mathbb{E}\left[Y\right]=\mathbb{E}\left[X^2\right]\ $, you haven't actually made any use of it.
