<s>[INST] How to calculate $E[X^2]$ for a die roll? Apparently:
$$
E[X^2] = 1^2 \cdot \frac{1}{6} + 2^2 \cdot \frac{1}{6} + 3^2\cdot\frac{1}{6}+4^2\cdot\frac{1}{6}+5^2\cdot\frac{1}{6}+6^2\cdot\frac{1}{6}
$$
where $X$ is the result of a die roll.
How come this expansion?
 [/INST] There are various ways to justify it.
For example, it follows from the definition of expectation and the law of the unconscious statistician.
Or consider the case $Y=X^2$ and computing $E(Y)$.
</s>