Can you please help to see where I did wrong?
There are 10 balls, and each ball to be place in bin 1 and bin 2. Each ball is placed indepedently. Let X be the number of balls in bin 1 and Y be the number of balls in bin 2. Compute Cov(X,Y).
My attempt: write X=X1+X2+-------+X10, where the Xi is the "ith" indicator for whether the balls are placed into the bin1 or not. Then Y=10-X.
Cov(X,Y)=E[XY]-E[X]E[Y]=E[X(10-X)]-E[X]E[10-X]=10E[X]-E[X^2]-E[X]*(10-E[X])
- E[X]=10*E[X1]=5.
E[X^2]=E[(X1+..X10)(X1+..+X10)] =E[X1X1+X2X2+..+X10X10]+E[X1X2+X1X3+X1X4+......X10X9] =0+10*9*1/4=90/4
So Cov(X,Y)=50-90/4-5*(10-5)=50-90/4-25=2.5
But the answer key said -2.5
Since each ball can go into bin 1 or bin 2, mutually exclusively and exhaustively, it's a binomial distribution:
$\operatorname{P}(X=x) = \dbinom{10}{x} \dfrac{1}{2^{10}} \\ \quad = \dfrac{10!}{x!(10-x)! 2^{10}}$
The expected value is thus:
$\operatorname{E}[X] = \sum\limits_{x=0}^{10} x\cdot\operatorname{P}(X=x) \\ \quad = \sum\limits_{x=0}^{10} \dfrac{10!}{(x-1)!(10-x)! 2^{10}} \\ \quad = 5$
The expected squared value is:
$\operatorname{E}[X^2] = \sum\limits_{x=0}^{10} x^2 \operatorname{P}(X=x) \\ \quad = \sum\limits_{x=0}^{10} \dfrac{10!x}{(x-1)!(10-x)! 2^{10}} \\ \quad = \dfrac{55}{2}$
Since $Y=10-X$ then:
$\operatorname{Cov}[X,Y] = \operatorname{E}[XY] - \operatorname{E}[X]\cdot\operatorname{E}[Y] \\ \quad = \operatorname{E}[10X-X^2] - \operatorname{E}[X]\cdot\operatorname{E}[10-X] \\ \quad = \operatorname{E}[X]^2-\operatorname{E}[X^2] \\ \quad = 25-\dfrac{55}{2} \\ \quad =\boxed{ -2.5}$
Alternatively, using your approach now the error is clear
Since the binning is exhaustive and mutually exclusive, then $Y=10-X$.
$\operatorname{Cov}(X,Y) = E[XY]-E[X]E[Y] \\ \quad = E[X(10-X)]-E[X]E[10-X] \\ \quad = 10E[X]-E[X^2]-E[X]\cdot(10-E[X]) \\ \quad = E[X]^2 - E[X^2]$
We can write $X=X_1+X_2+\dotsc+X_{10} = \sum\limits_{i=1}^{10} X_i$, where the $X_i$ is the binary indicator for whether the $i^{th}$ ball is placed into bin-1 (or not).
So $\operatorname{Cov}(X,Y)=25-\frac{55}{2}=\boxed{-2.5}$