can we apply linearity of expectations to $E[(X-Y)^2]$ if we do not know that X and Y are independent?
such that $E[(X-Y)^2]=(E[X]-E[Y]))^2$ ?
can we apply linearity of expectations to $E[(X-Y)^2]$ if we do not know that X and Y are independent?
such that $E[(X-Y)^2]=(E[X]-E[Y]))^2$ ?
No, we cannot apply the linearity of expectations because $f(x)=x^2$ is not a linear function. Squaring the difference and using the linearity of expectations leads to $$ \operatorname E[(X-Y)^2]=\operatorname E[(X^2-2XY+Y^2)]=\operatorname EX^2-2\operatorname E[XY]+\operatorname EY^2. $$ If $X$ and $Y$ are independent, then $\operatorname E[XY]=\operatorname EX\operatorname EY$ and hence $$ \operatorname E[(X-Y)^2]=\operatorname EX^2-2\operatorname EX\operatorname EY+\operatorname EY^2=(\operatorname EX-\operatorname EY)^2. $$ However, if $X$ and $Y$ are correlated, then $\operatorname E[XY]$ is not necessarily equal to $\operatorname EX\operatorname EY$.