Flipping two fair coins probability function $4$ Consider flipping two fair coins. Let $X = 1$ if the first coin is heads, and $X = 0$
if the first coin is tails. Let $Y = 1$ if the two coins show the same thing (i.e., both heads
or both tails), with $Y = 0$ otherwise. Let $Z = X + Y$, and $W = XY$.
(a) What is the probability function of $Z$?

Attempt:
$P(X = 1) = 1/2$
$P(X = 0) = 1/2$
$P(Y = 1) = 1/2$ since {HH, TT, TH, HT}, 2/4 times.
$P(Y = 0) = 1/2$ (not sure bout this)
(a)
Given $X = 1$, $Z = 2,1$
Given $X = 0$, $Z = 1, 0$
$P(Z = 2) = P(X = 1) + P(Y = 1) = 1/2 + 1/2 = 1$ [Book's answer is 1/4]
$P(Z = 1) = P(X = 1) + P(Y = 0) + P(X = 0) + P(Y = 1) = 2$ [1/2 book]
$P(Z = 0) = P(X = 0) + P(Y = 0) = 1$ [1/4 book]
Could someone explain to me why they multiply instead of adding them? Thanks

You're on the right track. You can case out the whole function since there are only four cases.
\begin{array}{|c|c|c|c|c|c|}
\hline
Coin 1& Coin 2 & X & Y & Z & W \\ \hline
H & H & 1 & 1 & 2 & 1\\ \hline
H & T & 1 & 0 & 1 & 0\\ \hline
T & H & 0 & 0 & 0 & 0\\ \hline
T & T & 0 & 1 & 1 & 0\\ \hline
\end{array}
Note that $P(Z) \not= P(X) + P(Y)$
