# Probability of getting the required pattern on rolling a die

I have a fair six-sided die and I keep rolling it til I get a pattern of 3 consecutive numbers say 1-2-3. I want to find the probability of me rolling the die an odd number of times till I achieve my required pattern.

I am unable to comprehend the outcomes that are in my favor.

For $0\le k\le 2$, let $p_k$ be the probability that the first occurrence of the roll sequence $1,2,3$ occurs after an odd number of (future) rolls, given that the prior $k$ rolls (from oldest to most recent) match the first $k$ terms of $1,2,3$.

Our goal is to find $p_0$.

Then we have the following system $$\begin{cases} p_0=\left({\large{\frac{1}{6}}}\right)(1-p_1)+\left({\large{\frac{5}{6}}}\right)(1-p_0)\\[4pt] p_1= \left({\large{\frac{1}{6}}}\right)(1-p_2) +\left({\large{\frac{1}{6}}}\right)(1-p_1) +\left({\large{\frac{2}{3}}}\right)(1-p_0) \\[4pt] p_2={\large{\frac{1}{6}}} +\left({\large{\frac{1}{6}}}\right)(1-p_1) +\left({\large{\frac{2}{3}}}\right)(1-p_0) \end{cases}$$ of $3$ linear equations, in $3$ unknowns.

Solving the system, we get $p_0={\large{\frac{216}{431}}}$.

Explanation:

Initially, there are no prior live terms to keep track of.

At any point before the first occurrence of the roll sequence $1,2,3$, the number of prior live terms is either $0$, $1$, or $2$.

• If the prior roll is $1$, then $k=1$ (we have one prior live term).$\\[4pt]$
• If the last two rolls (oldest to most recent) are $1,2$, then $k=2$ (we have two prior live terms).$\\[4pt]$
• Otherwise, we have $k=0$ (the number of prior live terms is zero).

The number of prior live terms (i.e., the value of $k$) can be regarded as the state of the game.

Note that $p_k$ is the probability of success, given state $k$, in an odd number of future rolls. Hence, after the next roll, we want the probability of failure, not success. That explains the expressions of the form $(1-p_j)$ on the right-hand side of each equation.

Now let's consider the equations, one at a time . . .

When $k=0$, there are two possibilies:

• If the next roll is $1$ (probability ${\large{\frac{1}{6}}}$), the state changes to $k=1$.$\\[4pt]$
• Otherwise (probability ${\large{\frac{5}{6}}}$), the state remains at $k=0$.

Therefore we have $p_0=\left({\large{\frac{1}{6}}}\right)(1-p_1)+\left({\large{\frac{5}{6}}}\right)(1-p_0)$.

When $k=1$, there are three possibilies:

• If the next roll is $2$ (probability ${\large{\frac{1}{6}}}$), the state changes to $k=2$.$\\[4pt]$
• If the next roll is $1$ (probability ${\large{\frac{1}{6}}}$), the state remains at $k=1$.$\\[4pt]$
• Otherwise (probability ${\large{\frac{2}{3}}}$), the state changes to $k=0$.

Therefore we have $p_1= \left({\large{\frac{1}{6}}}\right)(1-p_2) +\left({\large{\frac{1}{6}}}\right)(1-p_1) +\left({\large{\frac{2}{3}}}\right)(1-p_0)$.

When $k=2$, there are three possibilies:

• If the next roll is $3$ (probability ${\large{\frac{1}{6}}}$), the game is over, and we have success.
• If the next roll is $1$ (probability ${\large{\frac{1}{6}}}$), the state changes to $k=1$.$\\[4pt]$
• Otherwise (probability ${\large{\frac{2}{3}}}$), the state changes to $k=0$.

Therefore we have $p_2={\large{\frac{1}{6}}} +\left({\large{\frac{1}{6}}}\right)(1-p_1) +\left({\large{\frac{2}{3}}}\right)(1-p_0)$.

• Cool! I was going to say 'darn close to $\frac{1}{2}$ so might as well set to that and call it a day' ... but that's great you got the exact answer – Bram28 Jul 4 '18 at 17:55
• How did you get that system of equations? – saisanjeev Jul 10 '18 at 11:19
• @saisanjeev: I edited in an explanation. – quasi Jul 10 '18 at 15:25