Expectations are cool, let me show you why!
Uncentered variance and centered variance are two ways of measuring the second moment over data
The centered variance is calculated by subtracting every single data point by the mean and then squaring that difference and taking the average. The uncentered variance is simply squaring every single data point and then taking the average.
You can think of it as centered, meaning you’re first normalizing to the mean, whereas in the uncentered case you are taking each value at its face and performing the calculation without normalizing to the mean.
Here are the two expectations which represent the two types of variance, but in fact the centered variance can be written two ways:
\[\mathbb{E}[X^2]\] \[\mathbb{E}\!\left[(X - \mathbb{E}[X])^2\right] = \mathbb{E}[X^2] - (\mathbb{E}[X])^2\]Here I’ll demonstrate the cool mathematical relation which leads to both expectations for centered variance being equivalent:
\[\begin{aligned} \mathbb{E}\!\left[(X - \mathbb{E}[X])^2\right] &= \mathbb{E}\!\left[X^2 - 2X\mathbb{E}[X] + (\mathbb{E}[X])^2\right] \\ &= \mathbb{E}[X^2] - 2\mathbb{E}[X]\mathbb{E}[X] + (\mathbb{E}[X])^2 \\ &= \mathbb{E}[X^2] - (\mathbb{E}[X])^2 \end{aligned}\]