Interchange of expected value and summation Hey guys I'm studying Statistics and I'm currently at unbiased estimators. I'm trying to find the estimators for different problems. My question is : I know that the following formula holds
$$E (\sum_{i=0}^n X_{i}) =\sum_{i=0}^n(E( X_{i}))$$
where $X_{i}$ are the possible values of a random vector. I think this is true because of Fubini's theorem but correct me if I am wrong. My question is if the following formula is also true
$$E (\sum_{i=0}^n(X_{i}-X)^2) =\sum_{i=0}^n(E( X_{i}-X)^2)$$
where by $X$ I mean the $X=(\sum_{i=0}^n X_{i})/n$. Of course $(X_{i}-X)^2$ isn't a linear equation so I don't know if that means anything.
Can you please explain me if both formulas are true and why?
 A: 
I know that the following formula holds
$$\mathsf E (\sum_{i=0}^n X_{i}) =\sum_{i=0}^n(\mathsf E( X_{i}))$$
where $X_{i}$ are the possible values of a random vector. I think this is true because of Fubini's theorem but correct me if I am wrong.

Well, it has not much to do with Fubini's theorem.   Expectation is a Linear operation, often represented as an abstracted integration.   (PS: the index of a vector is usually based from 1.)
$$\mathsf E(\sum_{i=1}^n X_k) ~{=~ \int_\Omega \sum_{i=1}^n X_i(\omega)~\mathsf P(\mathrm d \omega)\\ =~ \sum_{i=1}^n \int_\Omega X_i(\omega)~\mathsf P(\mathrm d \omega)\\ =~ \sum_{i=1}^n \mathsf E(X_i)}$$

My question is if the following formula is also true $\newcommand{\bar}[1]{\overline{#1}}$
$$\mathsf E (\sum_{i=0}^n(X_{i}-\bar X)^2) =\sum_{i=0}^n(\mathsf E( X_{i}-\bar X)^2)$$
where by $\bar X$ I mean the $\bar X=(\sum_{i=0}^n X_{i})/n$. Of course $(X_{i}-\bar X)^2$ isn't a linear equation so I don't know if that means anything.
Can you please explain me if both formulas are true and why?

I've added the bar over the $X$, but left the brackets where they were; which is where you've gone awry.   $\mathsf E((X_i-\bar X)^2)$ is not the same thing as $\mathsf E(X_i-\bar X)^2$.
Indeed $(X_i-\bar X)^2$ is not a linear operation, it is a measure; the Expectation operator is what is linear.
$$\mathsf E\left(\sum_{i=1}^n(X_i-\bar X)^2\right) ~{=~\int_\Omega \sum_{i=1}^n(X_i(\omega)-\bar X)^2\,\mathsf P(\mathrm d\omega) \\=~ \sum_{i=1}^n \int_\Omega (X_i(\omega)-\bar X)^2\,\mathsf P(\mathrm d\omega)\\=~\sum_{i=1}^n \mathsf E\left(( X_i-\bar X)^2\right)}$$
A: The expectation operator is linear. This means that you can change the order of taking expectations and taking sums. In both of the formulas that you state, this is exactly what is done: on the left-hand sides, the sum is taken first and then the expectation, on the right-hand sides the expectation is taken first and then the sum. Both formulas are correct .
