Suppose I have a random variable that takes on a value of 10 with p(x=10)=.7 and a value of 20 with p(x=20) = .3.
The E(X) = .7(10)+.3(20) = 13.
The variance would be the expected value of the differences from the mean for each x.
Var(X) = .7(13-10)^2 + .3(20-13)^2 = 21.
The posted solution has (.7)(.3)(10)^2 which I've identified as (.7)(.3)(20-10)^2. This also equals 21. I just can't see how that identity works.
In general it would look like this:
E(X) = p*(1-p)*(b-a)^2 where P(x=b) = p and P(x=a) = 1-p.
I'm just not seeing it for some reason, but it appears to always work. I've tried expanding all the expressions out and comparing, but I can't get them to match up.
Suppose that $X$ only takes two values $a$ and $b$ with probabilities of $P(X=a)=p$ and $P(x=b)=1-p$. $E[X]=pa+(1-p)b$. \begin{align*} V(X)&=p(a-E[X])^2+(1-p)(b-E[X])^2\\ ={}&p[a-pa-(1-p)b]^2+(1-p)[b-pa-(1-p)b]^2\\ ={}&p(1-p)^2 (a-b)^2+(1-p)p^2(a-b)^2\\ ={}&p(1-p)(a-b)^2 \end{align*}