$E(X^2)$ calculation for fair die

In my book, the following equation is given for variance:

$Var(X) = E(X^2) - \mu^2$

When asked to compute the variance of a fair 6-sided die, they do the following calculation for $E(X^2)$:

$E(X^2) = \frac{1}{6}(1^2 +2^2+3^2+4^2+5^2+6^2)$

I understand that $\{1,...6\}$ are the possible values r.v. $X$ can take on. But what allows them to just square all the individual values? I was trying to justify it this way:

$E(X^2) = E(\sum_{i=1}^nX_i^2 + \sum_{i\neq j}X_iX_j)$

$E(X^2) = \sum_{i=1}^n E(X_i^2) + \sum_{i\neq j}E(X_iX_j)$

However, it looks like in their solution, they have only considered the $\sum_{i=1}^n E(X_i^2)$ case.

• You are overthinking this: they are squaring since they are computing the expectation of $X^2$. As another example $E(X^3)=\frac16(1^3+\cdots+6^3)$, $E(2^X)=\frac16(2^1+\cdots+2^6)$ etc. Commented Jul 15, 2017 at 7:18
• Yes, my question is why they are allowed to do that under the terms specified by the general formula for $E(X^2)$. Additionally, since $X$ is technically a function, why are they allowed to square its outputs and say that's equal to $X^2$? Is it because $X(\omega) = r \in \mathbb{R}$ and $X(\omega)^2 = r^2 \in \mathbb{R}$ ? Commented Jul 15, 2017 at 7:20
• I've edited my answer below a few times. Now you see the final answer. Commented Jul 15, 2017 at 8:01
• @Fakemistake thanks for letting me know Commented Jul 15, 2017 at 10:20

1 Answer

It follows by definition of $E(X^n)$! That's for $\Omega=\lbrace 1,2,3,4,5,6\rbrace$ and $n=2$ $$E(X^2):=\int_{\Omega} X^2 dP=\sum_{\omega\in\Omega}\omega^2\cdot P(\lbrace{X=\omega}\rbrace)$$ and for the discret uniform distribution $P$ we have $P(\lbrace{X=\omega}\rbrace)=1/6$