# Finding the expected value for the mean squared

The question I tried to solve, but failed, goes like this:

Find the expected value of $$(\bar{X}_n)^2$$ and find an ubiased estimator for $$\mu^2$$.

This is the solution given by the TA:

$$E[(\frac{1}{n}\sum^n_{i=1} X_i)^2]$$ $$= E[\frac{1}{n^2}\sum^n_{i=1} X_i \sum^n_{k=1} X_k]$$ $$= \frac{1}{n^2}\sum^n_{i=1} E[X^2_{i}] + \frac{1}{n^2}\sum^n_{i=1} \sum_{k \neq i} E[X_i]E[X_k]$$ $$= \frac{1}{n}(\sigma^2 + \mu^2) + \frac{n-1}{n}\mu^2$$ $$= \mu^2 + \frac{\sigma^2}{n}$$

Hence, the unbiased estimator is: $$(\bar{X}_n)^2 - \frac{\hat{\sigma}^2}{n}$$

• Where did this $$X_k$$ come from? why didn't he just use $$\frac{1}{n}\sum^n_{i=1} X_i$$ twice?
• I don't understand the second line at all. Why is there $$\frac{1}{n^2}$$ two times? and how did he separate the sum into two parts like that?
Here is a more expanded version of the derivation: \begin{align} E\left[\bar X_n^2\right] &= E\left[\left(\frac{1}{n}\sum^n_{i=1} X_i\right)^2\right] \\ &= E\left[\left(\frac{1}{n}\sum^n_{i=1} X_i\right)\left(\frac{1}{n}\sum^n_{i=1} X_i\right)\right] \\ &= E\left[\left(\frac{1}{n}\sum^n_{i=1} X_i\right)\left(\frac{1}{n}\sum^n_{k=1} X_k\right)\right] \\ &= E\left[\frac{1}{n^2}\left(\sum^n_{i=1} X_i\right)\left(\sum^n_{k=1} X_k\right)\right] \\ &= E\left[\frac{1}{n^2}\left(\sum^n_{i=1} X_i\right)a\right] \\ &= E\left[\frac{1}{n^2}\sum^n_{i=1} a X_i\right] \\ &= E\left[\frac{1}{n^2}\sum^n_{i=1} \left(\sum^n_{k=1} X_k\right) X_i\right] \\ &= E\left[\frac{1}{n^2}\sum^n_{i=1} \left(\sum^n_{k=1} X_kX_i\right)\right] \\ &= \frac{1}{n^2}\sum^n_{i=1} \sum^n_{k=1} E\left[X_kX_i\right] \\ \end{align} Notice that, in the inner summation, as we are iterating over $$k$$, and because $$k$$ and $$i$$ both range from $$1$$ to $$n$$, then there will come a point when $$k = i$$. This means that the inner summation becomes $$\sum^n_{k=1} E\left[X_kX_i\right] = E[X_iX_i] + \sum_{k \neq i} E[X_kX_i] = E[X_i^2] + \sum_{k \neq i} E[X_kX_i]$$ and so \begin{align} E\left[\bar X_n^2\right] &= \frac{1}{n^2}\sum^n_{i=1} \sum^n_{k=1} E\left[X_kX_i\right] \\ &= \frac{1}{n^2}\sum^n_{i=1} \left(E[X_i^2] + \sum_{k \neq i} E[X_kX_i]\right) \\ &= \frac{1}{n^2}\sum^n_{i=1} E[X_i^2] + \frac{1}{n^2}\sum^n_{i=1}\sum_{k \neq i} E[X_kX_i] \end{align} Because $$X_k$$ and $$X_i$$ are assumed to be independent and identically distributed for $$k \neq i$$, then $$E\left[X_kX_i\right] = E[X_k]E[X_i]$$ and $$E[X_k] = E[X_i]$$ and so \begin{align} E\left[\bar X_n^2\right] &= \frac{1}{n^2}\sum^n_{i=1} E[X_i^2] + \frac{1}{n^2}\sum^n_{i=1}\sum_{k \neq i} E[X_k]E[X_i] \end{align} I'll leave the rest up to you.