Let X1,X2,...,Xn be a set of i.i.d. random variables with mean μ and varaince σ2. Define X=n1∑iXi. Then
i∑(Xi−X)2=i∑(Xi−μ−(X−μ))2=i∑(Xi−μ)2−2i∑(Xi−μ)(X−μ)+n(X−μ)2=i∑(Xi−μ)2−n(X−μ)2Define S=∑iXi. Note that S is a random variable with mean nμ and variance nσ2. Therefore,
E[i∑(Xi−X)2]=i∑E[(Xi−μ)2]−nE[(X−μ)2]=nσ2−n1E[(S−nμ)2]=(n−1)σ2Another way of looking this is that,
n1i∑(Xi−X)2=n1(i∑Xi2−2X(i∑Xi)+n(X)2)=n1(i∑Xi2−n(X)2)=n1i∑Xi2−X2=n1i∑Xi2−μ2−(X2−μ2)Therefore,
E[n1i∑(Xi−X)2]=σ2−n1σ2We can also prove this via linear algebra. Let X=(X1,X2,...,Xn) be a n-dimension vector. Also, denote e=(1,1,...,1). Then
Xi∑(Xi−X)2=n1eTX=(X−n1eeTX)T(X−n1eeTX)=XT(I−n1eeT)T(I−n1eeT)X=XT(I−n1eeT)(I−n1eeT)X=XT(I−2n1eeT+n21eeTeeT)X=XT(I−2n1eeT+n1eeT)X=XT(I−n1eeT)X=Tr[XT(I−n1eeT)X]=Tr[(I−n1eeT)XXT]Since E[XXT]=μ2eeT+σ2I,
E[i∑(Xi−X)2]=Tr[(I−n1eeT)E[XXT]]=Tr[(I−n1eeT)(μ2eeT+σ2I)]=Tr[(eeT−eeT)μ2+(I−n1eeT)σ2]=Tr[(I−n1eeT)σ2]=Tr[I−n1eeT]σ2where n−1 is the trace as well as the rank of I−n1eeT.