$ Var(X) = E((X -E(X))^2) = \sum_x p(x)(x-E(X))^2 $
How the last line came from it's previous line? can anyone kindly show me all of the steps? I know from common sense of probability theory that it does make sense, but i want to see mathematically how it came. I also know that $ Var(X) = E((X -E(X))^2) $
thanks in advance
The Expected Value of a given function $f$ of a random variable $x$ in a discrete space is pretty much by definition $$ E(f(X))=\sum\limits_xp(x)f(x) $$ In the example you give $$ f(x)=(x-E(X))^2 $$