variance (also known as second central moment) is a way of measuring spread:
\begin{align} Var(X) &= E[(X-E(X))^{2}] \\ &= E[X^{2}] - (E[X])^{2} \\ &= \qty(\sum_{x}^{} x^{2} p\qty(X=x)) - (E[X])^{2} \end{align}
“on average, how far is the probability of \(X\) from its expectation”
The expression(s) are derived below. Recall that standard deviation is a square root of the variance.
computing variance:
\begin{align} Var(X) &= E[(X - \mu)^{2}] \\ &= \sum_{x}^{} (x-\mu)^{2} p(X) \end{align}
based on the law of the Unconscious statistician. And then, we do algebra:
So, for any random variable \(X\), we say:
\begin{align} Var(X) &= E[X^{2}] - (E[X])^{2} \\ &= \qty(\sum_{x}^{} x^{2} p(X=x)) - (E[X])^{2} \end{align}
based on the law of Unconscious statistician.