Problem 14.1 Easy Free

Product of Heads and Tails

A fair coin is tossed nn times. Let XX be the number of heads and YY the number of tails. Find E[XY]\mathbb{E}[XY] as a quadratic expression in nn.

Work it out, then compare with the answer.

SolutionShow the worked solution

Since every toss is either a head or a tail, Y=n−XY = n - X, where X∼Bin(n,12)X \sim \mathrm{Bin}(n,\tfrac12). Hence

E[X]=n2,Var⁡(X)=n4,E[X2]=Var⁡(X)+E[X]2=n4+n24.\mathbb{E}[X] = \frac{n}{2}, \qquad \operatorname{Var}(X) = \frac{n}{4}, \qquad \mathbb{E}[X^2] = \operatorname{Var}(X) + \mathbb{E}[X]^2 = \frac{n}{4} + \frac{n^2}{4}.

By linearity,

E[XY]=E[X(n−X)]=n E[X]−E[X2]=n22−n2+n4=n2−n4.\mathbb{E}[XY] = \mathbb{E}[X(n-X)] = n\,\mathbb{E}[X] - \mathbb{E}[X^2] = \frac{n^2}{2} - \frac{n^2+n}{4} = \frac{n^2-n}{4}.
E[XY]=n2−n4=n(n−1)4\boxed{\mathbb{E}[XY] = \frac{n^2-n}{4} = \frac{n(n-1)}{4}}

Alternative. Let HiH_i and TjT_j be the indicators that toss ii is a head and that toss jj is a tail. Then

XY=∑i,jHiTj.XY = \sum_{i,j} H_i T_j .

When i=ji=j we have HiTi=0H_iT_i = 0. When i≠ji \ne j the tosses are independent, so E[HiTj]=14\mathbb{E}[H_iT_j] = \tfrac14. There are n(n−1)n(n-1) ordered pairs with i≠ji \ne j, which gives E[XY]=n(n−1)4\mathbb{E}[XY] = \tfrac{n(n-1)}{4} again.

Key idea. Since E[X] E[Y]=n2/4\mathbb{E}[X]\,\mathbb{E}[Y] = n^2/4, the answer says Cov⁡(X,Y)=−Var⁡(X)=−n/4\operatorname{Cov}(X,Y) = -\operatorname{Var}(X) = -n/4. This is the price of the constraint X+Y=nX+Y=n.