# Proving an identity involving sample variance

Suppose that $X_1,\cdots,X_n$ are i.d.d. Show that

$$\mathbb{E}\left[(X_1 - X_2)^2 \mid \sum_{i=1}^n X_i, \sum_{i=1}^n X_i^2\right] = 2s_n^2$$

where

$$s_n^2 = \frac{1}{n-1} \sum_{i=1}^n (X_i - \bar{X}_n)^2$$

I am wondering if the question is wrong because I proved a slightly different identity, and the proof I came up with seems pretty straightforward.

I started with considering

$$\mathbb{E}\left( \sum X_i^2 \mid \sum X_i=p, \sum X_i^2 = q\right) = q$$

Since $X_1,\cdots,X_n$ are i.i.d, we have

$$n\mathbb{E}\left(X_i^2 \mid \sum X_i = p, \sum X_i^2 = q\right) = q$$

In particular, this means that

$$\mathbb{E}\left( X_1^2 + X_2^2 \mid \sum X_i=p, \sum X_i^2 = q\right) = \frac{2q}{n}$$

We then consider

\begin{align} \mathbb{E}\left( X_i X_j \mid \sum X_i=p, \sum X_i^2 = q\right) &= \mathbb{E}(X_i \mid \cdots) \mathbb{E}(X_j \mid \cdots) \\ &= \mathbb{E}^2\left( X_i \mid \sum X_i=p, \sum X_i^2 = q\right) \\ &= \left( \frac{p}{n}\right)^2 \end{align}

In particular, this means

$$\mathbb{E}\left( 2X_1 X_2 \mid \sum X_i = p, \sum X_i^2 = q\right) = 2 \frac{p^2}{n^2}$$

So

$$\mathbb{E}\left[(X_1 - X_2)^2 \mid \sum_{i=1}^n X_i, \sum_{i=1}^n X_i^2\right] = \frac{2q}{n} - 2 \frac{q^2}{n^2}$$

Recall that

$$(n-1) s_n^2 = -n \bar{x}^2 + \sum x_i^2$$

So we have

\begin{align} \frac{2q}{n} - 2 \frac{q^2}{n^2} &= 2 \left( \frac{\sum x_i^2}{n} - \bar{x_n}^2\right) \\ &= 2 \left( \frac{n-1}{n} s_n^2 + \bar{x_n}^2 - \bar{x_n}^2 \right) \\ &= 2 \frac{n-1}{n} s_n^2 \end{align}

Why do I have an extra $\frac{n-1}{n}$?

Please see the step following your statement "We then consider...". $X_{i}$ and $X_{j}$ are marginally independent. Why will they be independent given the sum?