# Finding expected value of conditional probability distribution

Suppose we throw a fair dice, and let $X$ be the random variable representing each face (each result: $1,2,3,4,5,6$).
Suppose that we drew $k$ on the dice; we then flip a fair coin $k$ times.
let $Y$ be the random variable representing how many times we drew $H$ (head).
Now, I need to calculate $E(Y|X=3)$, and $E(Y)$.

The random variable $Z=(Y|X=3)$ distribution is:

$\mathbb{P}_Z(z=0)=\mathbb{P}_Z(\left\{TTT\right\})=\frac{1}{8}$
$\mathbb{P}_Z(z=1)=\mathbb{P}_Z(\left\{HTT,THT,TTH\right\})=\frac{3}{8}$
$\mathbb{P}_Z(z=2)=\mathbb{P}_Z(\left\{HHT,HTH,THH\right\})=\frac{3}{8}$
$\mathbb{P}_Z(z=3)=\mathbb{P}_Z(\left\{HHH\right\})=\frac{1}{8}$

So finding $E(Z)$ is easy.
But I have no idea how to find $E(Y)$, beacuse I am not really sure how the joint distribution table looks like for $X$ and $Y$ - it's dimensions depends on the $X=x$ value. meaning, for every $x\in X$, $Y$ gets different possible values!
for example, what would be $\mathbb{P}_{X,Y}(X=2,Y=6)$? we don't know, because we throw the coin only two times!

-
From what you told us, it seems $P(X=2,Y=6)=0$. One way of finding $E[Y]$ is finding $E[Y|X=k]$ for each $k$ and then applying $E[Y] = \sum_{k=1}^{6}{E[Y|X=k]P(X=k)}$. – madprob Jan 13 '14 at 16:00
Beware that "The random variable Z=(Y|X=3)" is a nonexistent object. – Did Jan 13 '14 at 16:53
Thank you all for the help. – so.very.tired Jan 13 '14 at 20:47
@Did, what's wrong with Z? why is it nonexistent? – so.very.tired Jan 14 '14 at 18:57
Because the notion is in no (decent) textbook. How would you define it? – Did Jan 14 '14 at 19:26

Because the probability of head is the same as the probability of tail, $E(Y|X=3)=3-E(Y|X=3)$ which gives $E(Y|X=3)=1.5$. Thus, $E(Y)=\sum_{j=1}^6 E(Y|X=j)/6 =\sum_{j=1}^6 (j/2)/6 = 6 \times (6+1) /24 = 42/24=7/4$.

-

One can do the calculation "from basics," but there are faster ways.

Given that $X=k$, the random variable $Y$ has binomial distribution, $k$ trials, probability of success $\frac{1}{2}$. Thus $E(Y|X=k)=\frac{k}{2}$.

Then $E(Y)=E(E(Y|X))=\frac{1}{6}\left(\frac{1}{2}+\frac{2}{2}+\cdots+\frac{6}{2}\right)=\frac{7}{4}$.

Remark: The joint distribution of $X$ and $Y$ can be written down. The probability that $X=k$ and $Y=y$ is $\frac{1}{6}\binom{k}{y}\left(\frac{1}{2}\right)^y$. Then we can use the table directly to find $E(Y)$, or first use the table to write down the distribution of $Y$, and then $E(Y)$. That is less efficient than working directly with expectations.

-
You've swapped an $X$ and $Y$ there. – Byron Schmuland Jan 13 '14 at 16:04
Thank you, fixed. – André Nicolas Jan 13 '14 at 16:11
Look at the sentence that begins with the word "Thus". – Byron Schmuland Jan 13 '14 at 16:13