# A fair die is rolled $N > 6$ times. What is the probability the last 6 rolls were exactly $1,2,3,4,5,6$?

You rolls a fair die $N > 6$ times and you want to rolls the sequence $1,2,3,4,5,6$ in this order.

What is the probability that the last 6 rolls were (in consecutive order) $1,2,3,4,5,6$, (So, on the Nth roll you get a 6, on the $(N-1)$th roll you get a 5, etc.), AND you did not roll this sequence any times before the last 6 rolls.

If I state another way, what is the probability that you roll the sequence 1,2,3,4,5,6 starting from the $(N-5)$th roll and you did not roll this sequence starting from any roll before the $(N-5)$th roll?

This is not a homework problems, just something I'm thinking about.

• For each specific N, you will have a probability. So, you want a formula or algorithm that generalizes for any N, right? – JLee Jan 7 '15 at 20:15
• Yes, an explicit formula for the probability that depends on N is what I would like. – Curiosity Jan 7 '15 at 20:26

For $n\ge 6, 0\le r\le 6$, let $p_r(n)$ be the probability that $n$ rolls end in $1,2,\ldots,r$ and $1,2,3,4,5,6$ never occurs in the sequence. Then $p(n)=p_0(n)+\ldots+p_6(n)$ denotes the probability that $1,2,3,4,5,6$ never occurs within $n$ rolls. Clearly $p_r(6)=1$ for $r<6$ and $p_6(n)=0$ for all $n\ge 6$. Otherwise we have the following recursions: $$p_r(n+1)= \begin{cases}0&\text{if }r=6\\\frac16p_{r-1}(n)&\text{if }2\le r\le 5\\ \frac16(p_0(n)+\ldots+p_6(n))&\text{if }r=1\\ \frac56(p_0(n)+p_6(n))+\frac23(p_1(n)+\ldots+p_5(n))&\text{if }r=0\end{cases}$$ This allows some manual computations for small $n$. For the general solution this means that we have to find the eigenvalues and eigenvectors of the matrix $$\frac16\begin{pmatrix}5&4&4&4&4&4\\ 1&1&1&1&1&1\\ 0&1&0&0&0&0\\ 0&0&1&0&0&0\\ 0&0&0&1&0&0\\ 0&0&0&0&1&0\\ \end{pmatrix}$$ to find an explicit formula for the $p_r(n)$ and finally for $p(n)$ of the form $$\tag1p(n)=c_1\lambda_1^n+\ldots+c_6\lambda_6^n.$$ The answer to your question is then finally $$\tag2P= 6^{-6}\cdot p(N-6).$$
If my eigenvalue computations are right, we have \begin{align} \lambda_1&\approx\hphantom{-}0.999978564232\\ \lambda_2&\approx \hphantom{-}0.119473055129\\ \lambda_{3,4}&\approx \hphantom{-}0.033606052210\pm 0.112188066230\,i\\ \lambda_{5,6}&\approx-0.093331861891\pm 0.066102276039\,i\end{align} and I leave the determination of the $c_\nu$ as an exercise. For large $N$, the $c_1\lambda_1^n$ term in $(1)$ becomes dominant so that $(2)$ becomes $$\tag{2'}P\approx \alpha\cdot \lambda_1^N$$ with $\alpha = 6^{-6}c_1\lambda_1^{-6}$.
Remark: In the light of Ross Millikan's answer, note that $1-6^{-6}\approx 0.9999785665$. At first glance, the difference to $\lambda_1$ might be an artefact of my numeric calculation (PARI/GP with standard precision). But redoing my calculation with higher precision suggests that the difference ($\approx 2.297\cdot 10^{-9}$) is real.
• Could you say something about what $p_0(n)$ represents? It seems to me that $p(n)=p_1(n)+p_2(n)+ \cdots + p_6(n)$. – Matthew Conroy Jan 7 '15 at 23:34
For seven rolls the last six being $1,2,3,4,5,6$ rules out having $1,2,3,4,5,6$ before that, so the chance you get the first $1,2,3,4,5,6$ starting on roll $2$ is $1/6^6$. For any number of rolls below $12$ the odds of ending with the first $1,2,3,4,5,6$ are $1/6^6$. It is only with $12$ or more rolls that you can get $1,2,3,4,5,6$ before the end, so for $N\ge 12$ the probability is $P($no $1,2,3,4,5,6$ in the first $N-6$ rolls)$1/6^6$ Roughly speaking the chance of not getting $1,2,3,4,5,6$ in $M$ rolls is $(1-1/6^6)^{(M-5)}$ (this assumes independence, which is not quite true), so an approximate answer for the chance of getting $1,2,3,4,5,6$ for the first time at the end of $N$ rolls is $$\begin {cases} 0&N\lt 6\\1/6^6& 6\le N \lt 12 \\(1-1/6^6)^{N-11}/6^6&N \ge 12 \end {cases}$$