# Conditional expectation of a geometric die roll

We roll a die until we see the third six. Let X denote the number of rolls needed for the first six and Y the number of rolls needed for the third six. Find the conditional probability mass function of X given Y = y and compute E(X|Y).

In order to find the pmf, I should take f(x,y)/f(y). However, I could use some help finding these distributions.

For the expectation, that will follow simply from the pmf.

There is so much structure available in this problem that it would be a pity to leave it unnoticed...

1. You probably agree that $Y=X+X'+X''$ where $X'$ and $X''$ are the number of rolls needed to get the second six starting at the time of the first six, and the number of rolls needed to get the third six starting at the time of the second six, respectively. You also probably agree that the random variables $X$, $X'$ and $X''$ are i.i.d.

2. A consequence of the symmetry the last property reveals is that $$E[X\mid X+X'+X'']=E[X'\mid X+X'+X'']=E[X''\mid X+X'+X''].$$ Hence $$E[X\mid X+X'+X'']=\frac13E[X+X'+X''\mid X+X'+X''],$$ that is, $$E[X\mid Y]=\frac13E[Y\mid Y]=\frac13Y.$$ Thus, computing a conditional expectation starting from the conditional distribution is not always a good idea...

3. To compute the conditional distribution of $X$ conditionally on $Y=y$, note that $Y=y$ means that there are exactly two sixes amongst the $y-1$ first results. Once again by symmetry, the positions of these two sixes make a pair uniformly distributed in the set of all the pairs in $\{1,2,\ldots,y-1\}$. Note that there are ${y-1\choose 2}$ such pairs and that, for each $1\leqslant x\leqslant y-2$, there are $y-x-1$ such pairs whose smallest element is $x$. Thus, for every $y\geqslant3$ and $1\leqslant x\leqslant y-2$, $$P[X=x\mid Y=y]=\frac{2(y-x-1)}{(y-1)(y-2)}.$$ 4. Both results above are valid for $n$-sided dice, for any $n\geqslant2$, and even for unbalanced dice. The reason is the underlying symmetry we used, a consequence is that the formulas involve no probability $\frac16$ or $\frac56$ or any other.

5. Finally, this approach yields direct generalizations. For every $k\geqslant1$, let $Y_k$ denote the number of throws to get the $k$th six (hence $X$ and $Y$ above are actually $Y_1$ and $Y_3$), then, for every $1\leqslant k\leqslant\ell$, $$E[Y_k\mid Y_\ell]=\frac{kY_\ell}\ell,$$ and, for every $y\geqslant\ell\geqslant2$ and $1\leqslant x\leqslant y-\ell+1$, $$P[Y_1=x\mid Y_\ell=y]=\frac{{y-x-1\choose\ell-2}}{{y-1\choose\ell-1}}.$$

• Indeed, there are many approaches to this one. (+1) – robjohn Dec 11 '13 at 16:36

For example, if $Y=9$ there are $5$ ways for $X=3$: $$\hphantom{12}6\overbrace{\color{#888888}{6}\color{#888888}{6}\color{#888888}{6}\color{#888888}{6}\color{#888888}{6}}^{\text{5 ways}}6\\ 123456789$$ Thus, when $Y=y$ there are $y-x-1$ ways for $X=x$.

The number of ways for $Y=y$ is $\binom{y-1}{2}$, the number of ways to place the first two $6$s. Let's check using the formula: \begin{align} \sum_{x=1}^{y-2}y-x-1 &=(y-1)(y-2)-\sum_{x=1}^{y-2}x\\ &=(y-1)(y-2)-\frac{(y-1)(y-2)}{2}\\ &=\frac{(y-1)(y-2)}{2}\\ &=\binom{y-1}{2} \end{align}

Compute the expected value: \begin{align} \mathrm{E}(X|Y)= &\frac1{\binom{y-1}{2}}\sum_{x=1}^{y-2}(y-x-1)x\\ &=\frac1{\binom{y-1}{2}}\sum_{x=1}^{y-2}\left(y\binom{x}{1}-2\binom{x+1}{2}\right)\\ &=\frac1{\binom{y-1}{2}}\left(y\binom{y-1}{2}-2\binom{y}{3}\right)\\ &=y-2\frac{\frac y3\binom{y-1}{2}}{\binom{y-1}{2}}\\ &=\frac y3 \end{align}

\begin{align} \Pr(X=x) & = \Pr(\text{no 6s on first x-1 trials and 6 on xth trial} \\[10pt] & =\left(\frac 5 6 \right)^{x-1}\cdot\frac 1 6. \end{align}

\begin{align} \Pr(Y=y) & = \Pr(\text{exactly two 6s on first y-2 trials and 6 on yth trial}) \\[10pt] & = \binom{y-2}{2}\left(\frac 5 6 \right)^{y-4}\left(\frac 1 6\right)^2 \cdot\frac 1 6. \end{align}

And: \begin{align} \Pr(X=x\ \&\ Y=y) & = \Pr(\text{no 6s on first x-1 trials and 6 on xth trial and} \\[10pt] & \phantom{=\Pr(} \text{exactly one 6 on next (y-2)-x trials and 6 on yth trial}) \end{align} etc.