# Expected number of rolls until a number appears 2 times discussion

I have the following problem. How many times you have to roll a die until you get two 6 or two 5 in a row.

Problems similar to this one have been discussed in the forum in links like:

I "solved" this problem as follows:

Let A the event of two consecutives 6 or two consecutive 5 in a row, and B the event of two consecutive equal numbers in a row. Then, it follows that:

$$$$P(A) = P(A \cap B) = P(A/B)P(B)$$$$

$$P(A/B)=2/6$$ because if you already know that there are two identical numbers in a row then A can happen in 2 ways (5,5) and (6,6) over the sample space (i,i), $$1\leq i \leq 6.$$

But P(B) is a little bit more tricky. I know that the answer is 1/7 (I run a simple program to compute this number) but for me is counter intuitive.

In that case the Expected value would be = 21 because I expect 1 "win" combination out of 21 rolls.

My confusion is that I would have answered 1/6 instead of 1/7 in $$P(B)$$ because, no matter what number came out from the first dice, the second has 1/6 probability to match that number. Why this intuition fails? I know the answer is in [2] but I still can not handle the intuition on this.

A generalization of this result can be found here: Expected number of rolls until a number appears $k$ times

Moreover, this problem is often to get confused with the 1/36 probability of throwing two dices simultaneously.

Links where to the discussion of this topic:

• What quantity are you trying to compute? Some of the links refer to problems asking for the "expected number of rolls until ...", while you seem to be trying to compute the probability of some event (two consecutive 6s or consecutive 5s, but in how many rolls?) Jan 13, 2021 at 18:42
• It is very hard to follow what you wrote. You start out asking about an expected number of turns, but then you start computing some probability or other.
– lulu
Jan 13, 2021 at 18:49
• Yes I know, but in this case if the probability is 1/7 it means the expected number of rolls have to be 7. Isnt it? Jan 13, 2021 at 18:51
• The probability of what is $\frac 17$? As you say, the probability that two consecutive throws match is obviously $\frac 16$.
– lulu
Jan 13, 2021 at 18:52
• ok I will edit the question. Jan 13, 2021 at 18:53

This sort of thing can easily be handled with states, and the symmetry makes it especially easy in this case.

There are three states where care about: $$S_5, S_6,S_{\emptyset}$$ according to whether the prior throw was a $$5$$, a $$6$$, or neither (we let $$S_{\emptyset}$$ include the starting state as well). Symmetry tells us that we expect it to take the same number of rolls to finish from $$S_5$$ as it does from $$S_6$$, let $$B$$ denote that expected number. Let $$A$$ denote the expected number starting from $$S_{\emptyset}$$, so the answer to the problem is $$A$$.

Considering the possible outcomes if you are in $$S_{\emptyset}$$ we see that $$A=\frac 13\times (B+1)+\frac 23\times (A+1)$$

Similarly, thinking about the possible outcomes if you are in $$S_5$$ or $$S_6$$ we see that $$B=\frac 16\times 1+\frac 16\times (B+1)+\frac 23\times (A+1)$$

Solving that system of equations yields $$A=21\quad \&\quad B=18$$ so the answer is $$\boxed {21}$$.

It seems you are trying to solve the problem by finding the probability that two consecutive throws are either both $$5$$ or both $$6$$, and then taking one over this probability. Similar to how the expected number of flips it takes to get heads when $$P(heads)=p$$ is $$1/p$$. However, this does not work here, since the sequences of pairs of flips are not independent.

Let $$X$$ be the number of rolls it takes to get two fives or two sixes in a row. Starting with zero rolls, three things can happen:

• Your first roll is between $$1$$ and $$4$$. In this case, the number of subsequent roll has the same distribution as $$X$$.

• You first roll is $$5$$ or $$6$$, and your second roll is different from the first roll. Again, the number of subsequent rolls is $$X$$.

• You first two rolls are both fives or both sixes. Here, $$X=2$$.

We get that $$X\stackrel{d}= \begin{cases} X+1 & \text{with probability }\frac{2}{3} \\ X+2 & \text{with probability }\frac{1}{3}\cdot \frac56 \\ 2 & \text{with probability }\frac{1}{3}\cdot \frac16 \\ \end{cases}\tag{*}$$ Here is the interpretation of the above equality; $$X$$ has the same distribution as a random variable which is equal to one of the three options above, selected with the given probabilities independently of $$X$$.

Now, taking expectations of both sides, you get $$E[X] = \frac23 \cdot E[X+1] + \frac13\cdot\frac56 \cdot E[X+2] + \frac13\cdot\frac16 \cdot 2$$ This lets you solve for $$E[X]$$.

As a side note, $$(*)$$ also implies that $$f(X)\stackrel{d}= \begin{cases} f(X+1) & \text{with probability }\frac{2}{3} \\ f(X+2) & \text{with probability }\frac{1}{3}\cdot \frac56 \\ f(2) & \text{with probability }\frac{1}{3}\cdot \frac16 \\ \end{cases}$$ for any function $$f$$. Using $$f(x)=x^2$$, then taking expectations, lets you find $$E[X^2]$$, and therefore $$\text{Var}(X)$$. Using $$f(x)=e^{tx}$$ lets you find the full moment generating function of $$X$$.