What is the expected number of rolls of a 6-sided die before getting a 2 followed immediately by a 3?

133 Views Asked by At

I am trying to calculate the expected number of rolls of a 6-sided die before getting a 2 followed immediately by a 3. Here's my solution,

Let the $E[N] = x$,

$x = \frac{1}{36}\left[ 2 + (1+1+x-1) + 4(x+2) \right] + \frac{30}{36}[x+1]$.

The first term is from the cases (1st toss, 2nd toss): (2,3), (2,2), (2, 1/4/5/6), and the second term is from when 1st toss is not a 2. This equation leads to x = 41. But, this is the wrong answer. The correct answer is 42. I think the mistake is in the $(1+1+x-1)$ term, but I am not sure why. I found a solution on the internet which says that this term is simply $(x+2)$. This doesn't make sense because $x$ is the unconditional expectation, whereas once we see that the 2nd toss is also a 2, there is obviously less number of rolls required to get a pattern of $23$. Can someone please explain this?

2

There are 2 best solutions below

7
On BEST ANSWER

Let $A$ be the expected number of still needed rolls continuing from a state that has not yet made any progress towards ending the chain, either as a result of having just rolled a number which is not a $2$ and having not just ended, or as a result of having just started the game. Let $B$ be the expected number of still needed rolls from the state that you have just recently rolled a $2$.

You have that $A=\frac{5}{6}(1+A)+\frac{1}{6}(1+B)$ and that $B=\frac{1}{6}(1)+\frac{1}{6}(1+B)+\frac{4}{6}(1+A)$

The first coming from the observation that while at the starting position, you either effectively remain at the starting position having rolled anything except a $2$ and then still need an additional $A$ expected rolls in addition to the roll(s) you've already made. For the second, you can either go from the second state to the winning end state, stay in the second state, or go back to the first.

Solving gives $A=36$ and $B=30$, so the answer to your question is $36$


Since there remains confusion, here is a quick and dirty javascript simulation, performing the experiment $100000$ times, resetting between each attempt. Running the simulation confirms the result to be near $36$

totalNumOfRolls = 0;
for(i=0;i<100000;i++){
prevRoll = 0;
curRoll = 0;
while (prevRoll != 2 || curRoll != 3){
prevRoll = curRoll;
curRoll = Math.floor(Math.random()*6)+1;
totalNumOfRolls++;
}
}
console.log(totalNumOfRolls/100000)
0
On

Since there are already other answers that use linearity of expectation directly to generate a simple equation for the sought-after value, let’s bring the big guns to bear instead. The process can be modeled by a three-state absorbing Markov chain with transition matrix

$$P = \begin{bmatrix}\frac56&\frac16&0\\\frac46&\frac16&\frac16\\0&0&1\end{bmatrix} = \begin{bmatrix}Q&R\\\mathbf 0&1\end{bmatrix}.$$

From the start state, if we roll a two, we advance to the next state, otherwise stay in the start state. That’s the first row of $P$. From the “I just rolled a two” state, we can either roll a three and end, roll a two and stay in the “I just rolled a two” state, or roll anything else and go back to the start state. That’s the second row. The third row says that “I rolled a three immediately after a two” is an absorbing state: once we get there, we stay in that state forever.

Using the standard techniques described here, we compute the fundamental matrix $$N = (I-Q)^{-1}= \begin{bmatrix}30&6\\24&6\end{bmatrix}.$$ This matrix consists of the expected number of visits to each state before reaching the absorbing state. If we start the process in the first state, then, the expected number of steps until absorption is the sum of the entries in the first row of $N$, namely, $36$.