derivation of the expected value for the variance

Hi Im taking a course about probability distribution in datascience and below is derivation of the expected value for the variance

  1. Variance = expected value of the squared difference from mean for any value. But generally, variance is just the difference between the value and its mean.

Why are we squaring and adding the expected value symbol?

$$\sigma^2 = E((Y - \mu)^2) = E(Y^2) - \mu^2$$

  1. For the first step in derivation, why do we multiply the summation of $p(x)$ with $(x - \mu)^2$? enter image description here

  2. How is this substitution valid? I cannot understand it. I know that $E(X)=p(X).X$

$E(X^2) = \sum P(X)*X^2$


The expected value of a random variable is defined as (without entering into probability/measure theory):

  • For discrete distribution $F$, we have $E(X)=\sum_x P_F(X=x) x$
  • For (absolutely) continuous distribution $F=\int f(x) dx$, we have $E(X) = \int f(x) dx$

Therefore, the first equality is just the definition of expected value for the discrete case.

And finally, the law of the unconscious statistician (LOTUS) states that $$E(g(X)) = \int g(x) f(x) dx$$ (for continuous F), or
$$E(g(X)) = \sum g(x) P(X=x)$$ (for discrete F).

  • $\begingroup$ Thanks but this dose not answer my question i already mention in point 3. that i know E(X)=p(X).X ,my question is on how LHS=RHS equations in above point 2,3 ? $\endgroup$ – Aj_MLstater Mar 1 at 20:08
  • $\begingroup$ @Aj_MLstater What about now? $\endgroup$ – An old man in the sea. Mar 1 at 20:20
  • $\begingroup$ Im totaly confused , can you please explain these part alone 2. E(X-mu) ^2 = summation p(X) *(X-mu)^2 3. E(X^2)=p(X).X^2 $\endgroup$ – Aj_MLstater Mar 1 at 20:23
  • $\begingroup$ @Aj_MLstater Take $g(X)=(X-E(X))^2$ in the LOTUS equation, and the rest follows. I've edited my question to reflect the LOTUS for the discrete case. $\endgroup$ – An old man in the sea. Mar 1 at 20:25
  • $\begingroup$ @Aj_MLstater is it clear now? $\endgroup$ – An old man in the sea. Mar 1 at 20:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.