# How to derive second moment of the sample mean

Suppose you have $$X_i$$ be i.i.d, such that $$E(X_i) = \mu$$ and $$Var(X_i) = \sigma^2$$. I know $$\overline{X}_n = \sum\limits_{i=1}^n X_i$$ and, as is standard $$E(\overline{X_n}) = \mu$$ and $$Var(\overline{X}_n) = \frac{\sigma^2}{n}$$.

I know you can derive that $$E\left(\overline{X}_n^2\right) = \frac{\sigma^2}{n} + \mu^2$$ using the identity $$E(\overline{X}^2_n) = Var(\overline{X}_n) + E(\overline{X_n})^2$$.

However, when I try to prove it directly from the definition of the sample mean, I get: $$E(\overline{X}^2_n) = E\left( \left( \frac{1}{n} \sum\limits_{i=1}^n X_i\right)^2\right) = \frac{1}{n^2} \sum\limits_{i=1}^n E\left(X_i^2 \right) = \frac{1}{n^2} \sum\limits_{i=1}^n (\sigma^2 + \mu^2) = \frac{1}{n^2} n(\sigma^2 + \mu^2)= \frac{\sigma^2 + \mu^2}{n}$$.

I am trying to figure out what I'm doing wrong

• HI: When you square the sum of the $X_{i}$ in the last equation, the sum is squared. So, all of the $X_i$ multiply all of the other $X_i$. So, you can't just say that it's equal to $\sum_{i=1}^{n} E(X_{i}^2)$. I didn't go through the algebra but, if you fix that, you'll probably get the answer above that you expect to get. Oct 19, 2020 at 1:27

$$\begin{equation*} \text{E}(\bar{X}^{2}_{n})=\text{E}\left[\left(\frac{1}{n}\sum_{i=1}^{n}X_{i}\right)^{2}\right] \neq \frac{1}{n^2}\sum_{i=1}^{n}\text{E}\left(X_{i}^2\right). \end{equation*}$$ For example, suppose that we have the following data: $$X=1,3,2$$. So, $$\begin{equation*} \text{E}(\bar{X}^{2}_{n})=\text{E}\left[\left(\frac{1}{n}\sum_{i=1}^{n}X_{i}\right)^{2}\right]=\text{E}\left[\left(\frac{1}{3}\sum_{i=1}^{3}X_{i}\right)^{2}\right]=\text{E}\left[\left(\frac{1}{3}[1+3+2]\right)^{2}\right]=\text{E}(2^{2})=4 \end{equation*}$$ on the other hand, $$\begin{equation*} \frac{1}{n^2}\sum_{i=1}^{n}\text{E}\left(X_{i}^2\right)=\frac{1}{3^2}\text{E}\left[\sum_{i=1}^{3}\left(X_{i}^2\right)\right]=\frac{1}{9}\text{E}\left(1^{2}+3^{2}+2^{2}\right)=\frac{14}{9} \end{equation*}$$ therefore, we can conclude that $$\text{E}(\bar{X}^{2}_{n}) \neq \frac{1}{n^2}\sum_{i=1}^{n}\text{E}\left(X_{i}^2\right)$$ as we have 4 $$\neq$$ 14/9.