conditional expectation of square given sum of iid variables

404 Views Asked by At

I have a simple question on conditional expectation but it appears I'm stuck a bit. I want to compute $E[X_1^2|X_1+\cdots+X_k=n]$ where the variables $X_1,\ldots,X_k$ are iid.

Now, due to the iid property, we have

$E[X_1^2|X_1+\cdots+X_k=n] = \frac{1}{k}E[X_1^2+\cdots+X_k^2|X_1+\cdots+X_k=n]$.

Furthermore,

$E[X_1^2+\cdots+X_k^2|X_1+\cdots+X_k=n] = E[(X_1+\cdots+X_k)^2-2\sum_{i<j}X_iX_j|X_1+\cdots+X_k=n] = n^2-2\binom{k}{2}E[X_1X_2|X_1+\cdots+X_k=n] = n^2-k(k+1)E[...]$.

Finally, by definition,

$E[X_1X_2|X_1+\cdots+X_k=n] = \sum_{x,y}xyP[X_1=x,X_2=y|X_1+\cdots+X_k=n] = \sum_{x,y} xyP[X_1=x]P[X_2=y]P[X_3+\cdots+X_k=n-x-y]/P[X_1+\cdots+X_k=n]$.

Something appears wrong to me? Is it the last equality?