# probability dice experiment

I am currently taking a probability course and I am stuck on a supposedly easy discrete probability question here:

Problem: Consider the experiment of rolling a fair die independently until the same number/face occurs 2 successive times and let $X$ be the trial on which the repeat occurs, e.g. if the rolls are $2,3,4,5,1,2,4,5,5$, then $X=9$.

a. find the probability function $f(x) = P(X=x)$

b. compute EX

Attempt at a solution: I know $X$ is discrete probability distribution, and that we are dealing with independent events. However, $X$ can be anything, up to infinity, or it may never happen where there are two successive values. Here's what I got:

$P(X=x) = f(x) = (5/6)^(x-1) * (1/6)$ for $x = 0,1,2,3,...$ and $0$ otherwise but I'm stuck here. please help

-
X=9, it's the 9th trial.. Sorry about that typo – jay Apr 30 '12 at 4:03
Also what exactly are you stuck on? You have derived that it's geometric. So you need help with $E(X)$? – Alex R. Apr 30 '12 at 4:03
Yea, the EX for this function and if this is indeed a geometric distribution, I have no way of telling – jay Apr 30 '12 at 4:05
It's the "obviously, the answer is..." part that confounded me – Alex R. Apr 30 '12 at 4:06
I'm seconding guessing my "obvious" insight now... – jay Apr 30 '12 at 4:07

You could solve this directly, expressing your answer as a sum of the form$\sum\limits_{n=2}^\infty n P[X=n]$. And, with a bit of work \, you could evaluate the sum explicitly (using the formula for the sum of a differentiated geometric series; see, e.g., the ideas here)).

The expected value is $\sum\limits_{n=2}^\infty n(5/6)^{n-2}(1/6)$. One can show this sum has value 7.

Or, you could find the expected value by conditioning on the result of the second roll:

Let $X$ be the number of rolls to obtain the same result twice in a row. Let $Y$ be the event that the second roll is the same as the first. Then \eqalign{ \Bbb E(X) &= \Bbb E(X\mid Y)P(Y)+\Bbb E(X\mid Y^C)P(Y^C)\cr &= \Bbb E(X\mid Y)\cdot{1\over 6}+E(X\mid Y^C)\cdot{5\over6}. } But $\Bbb E(X\mid Y)=2$ and $E(X\mid Y^C)=\Bbb E(X)+1$ (here, it's as if you started playing the game at the start again on the second roll). So \eqalign{ \Bbb E(X) &= 2\cdot{1\over 6}+(\Bbb E(X)+1)\cdot{5\over6}. } Solving the above for $\Bbb E(X)$ gives $$\Bbb E(X)=7.$$

-
wow. Awesome, thanks! – jay Apr 30 '12 at 4:34
@jay The nice thing about this sort of recursion method is that you can use it to answer questions like "What's the expected number of rolls until you have four of the same in a row?" The result outlined in my answer was simpler, which is why I went with it, but once you understand David's answer you can do more complicated variants. – Brett Frankel May 1 '12 at 0:34
@BrettFrankel: I think the two answers are complementary. Each approach is best some times, and knowing both gives a better feeling for the subject. – Ross Millikan May 13 '12 at 4:33

This is basically a geometric distribution. At each step, independent of whatever happened previously, you have a $1/6$ chance of rolling the same as you did on the previous try. You keep going until you get a success, and you are counting the number of tries until a success. Let's call this random variable $Y$.

Now here comes the only twist: You start not on the first try (on which it is impossible to duplicate a previous roll), but on the second. So $X$ is one more than $Y$, hence $f_X(t)=f_Y(t-1)$, and $E(X)=E(Y+1)$.

-
Thanks, so how is EX computed for this probability function? – jay Apr 30 '12 at 4:11
For a geometric distribution where the probability of success on a given try is $p$, the expectation is $\frac{1}{p}$ – Brett Frankel Apr 30 '12 at 4:12
Thanks so much!! – jay Apr 30 '12 at 4:18