So yesterday my professor wrote the following on the board:

$$\frac{1}{n}\sum_{i = 1}^{n}\left( x_i - \bar{X}\right)^2 = \frac{1}{n}\sum_{i = 1}^{n} x_i^2 - \bar{X}^2$$

where $\bar{X} = \frac{1}{n}\sum_{j = 1}^{n}x_j$ (This is just average) and the LHS(left hand side) is just sum of squares(averaged). (Or variance from the mean)

It took me a LONG time to realize that on the right hand side the $\bar{X}$ is NOT inside the summation... but even still I had trouble internalizing this identity. It just seems wrong to get rid of the cross terms...(i.e. $(a^2 + b^2 \neq a^2 + b^2)$)

I can prove this mathematically too, but I'm wondering if there's just an easy interpretation of this formula that I'm not wrapping my head around

Here's the mathematical proof in case anyone's interested:

$$\frac{1}{n}\sum_{i = 1}^{n}\left( x_i - \bar{X}\right)^2 = \frac{1}{n}\left( \sum_{i = 1}^{n}\left( x_i^2 - 2\bar{X}x_i + \bar{X}^2\right) \right) \text{(just squaring everything)}$$

$$= \frac{1}{n}\left( \sum_{i = 1}^{n}\ x_i^2 - 2\bar{X}\sum_{i = 1}^{n}x_i + \sum_{i = 1}^{n}\bar{X}^2\right)$$

$$ = \frac{1}{n}\left( \sum_{i = 1}^{n}\ x_i^2 - 2\bar{X}n\bar{X} + n\bar{X}^2 \right)$$

$$ = \frac{1}{n}\left( \sum_{i = 1}^{n}\ x_i^2\right) - \bar{X}^2 $$

I can believe the math, but it would be nice to have a deeper, more intuitive understanding of this identity if there even is one.

  • 2
    $\begingroup$ For approximately the last 2500 years people have been calling this the Pythagorean Theorem. $\endgroup$
    – whuber
    Commented Jan 7, 2023 at 20:30
  • 1
    $\begingroup$ @whuber uhhh what??? $\endgroup$
    – FafaDog
    Commented Jan 7, 2023 at 20:31
  • 1
    $\begingroup$ @whuber Sorry I feel embarrassed now. Is this the same Pythagoreas as in the right triangles? $\endgroup$
    – FafaDog
    Commented Jan 7, 2023 at 20:32
  • 2
    $\begingroup$ If you add $\bar{X}^2$ to both sides and look at a picture of a right triangle, the connection may become a little clearer. $\endgroup$
    – jbowman
    Commented Jan 7, 2023 at 22:01
  • 1
    $\begingroup$ There are many references to the Pythagorean Theorem here on CV. This really, truly is the ancient theorem in two dimensions: $(x_i-\bar x)$ is one vector and $\bar x(1,1,\ldots, 1)/\sqrt{n}$ is another vector. Euclid said three points determine a plane; this plane is determined by the origin (the zero vector) and these two vectors. Because the dot product of these vectors is zero, they are at right angles and the Pythagorean Theorem applies. $\endgroup$
    – whuber
    Commented Jan 8, 2023 at 0:14


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.