# Finding covariance from marginal densities.

A quarter is bent so that the probabilities of heads and tails are 0.40 and 0.60. If it is tossed twice, what is the covariance of Z, the number of heads obtained on the first toss, and W, the total number of heads obtained in the two tosses of the coin?

I noticed first they're clearly not independent so the covariance is not 0.

I calculated the marginal PMF's of Z and W and their expected values. I know Cov(Z,W) = E(ZW) - E(Z)E(W) but I can't calculate E(ZW) without the joint PMF. If I could recover the joint PMF from the marginals I could procede but from from what I've read that's only possible in certain cases.

I'm stuck, anyone have some hints for me?

We need $E(Z)$, $E(W)$, and $E(ZW)$. Undoubtedly familiar are $E(Z)=0.4$ and $E(W)=(2)(0.4)$.

We need $E(ZW)$. Let $S$ be the number of heads on the second toss. Then $W=Z+S$.

Thus $E(ZW)=E(Z(Z+S))=E(Z^2)+E(ZS)$. We have $E(Z^2)=0.4$, since $Z^2=Z$. And $Z$ and $S$ are independent, so $E(ZS)=E(Z)E(S)=(0.4)^2$.

Remark: Alternately, as you suggested, we could find the joint distribution function of $Z$ and $W$. This is a perfectly feasible way of doing things, it just takes a little longer.

• I find this solution very elegant. Now I'm saddened I couldn't think of it, I'm just now starting to grasp the usefulness of random variables I think. Thanks. – MeanByte Nov 3 '13 at 8:21
• You are welcome. Yes, random variables are central. Very usewful is expressing a random variable as a function of simpler random variables. – André Nicolas Nov 3 '13 at 15:23

There are four relevant events:

\begin{align*} \begin{array}{|c|c|c|c|c|} \hline \text{First toss}&\text{Second toss}&\text{Value of $Z$}&\text{Value of $W$}&\text{Probability}\\ \hline \text{Heads}&\text{Heads}&1&2&0\mathord.16\\ \text{Heads}&\text{Tails}&1&1&0\mathord.24\\ \text{Tails}&\text{Heads}&0&1&0\mathord.24\\ \text{Tails}&\text{Tails}&0&0&0\mathord.36\\ \hline \end{array} \end{align*}

Hence, $$\mathbb E(ZW)=(0\mathord.16)(1)(2)+(0\mathord.24)(1)(1)+(0\mathord.24)(0)(1)+(0\mathord.36)(0)(0)=0\mathord.56.$$

This table also reveals that \begin{align*} \mathbb E(Z)&\,=(0\mathord.16+0\mathord.24)(1)+(0\mathord.24+0\mathord.36)(0)=0\mathord.4,\\ \mathbb E(W)&\,=(0\mathord.16)(2)+(0\mathord. 24+0\mathord. 24)(1)+(0\mathord.36)(0)=0\mathord.8, \end{align*}

so that $$\operatorname*{cov} (Z,W)=\mathbb E(ZW)-\mathbb E(Z)\mathbb E (W)=0\mathord.56-(0\mathord.4)(0\mathord.8)=0\mathord.24.$$$\phantom{**Edited:** I had failed to take account of the coin being rigged earlier; sorry.}$

• Thanks a lot for this, your tabulation has made it clear how to approach situations like this. A very neat way of keeping the sample space in mind. Seems like a terribly simple problem looking back, but I think random variables had somewhat obscured the sample space in my mind leading to my confusion. – MeanByte Nov 5 '13 at 23:50