# What is the probability of rolling a 6-sided die 5 times, and getting at least 3 in a row?

I had been working on this problem, and ran into trouble because I couldn't easily use the "find the opposite probability and subtract from one" trick. So for example I think I can find the probability of getting at least two in a row rolling a die 5 times, by finding the probability of getting no duplicates at all and then subtracting from one to find the opposite: ( 1 - (5/6)^4 )

But how to find the probability of a sequence of at least three? The extension of the problem is to write a formula generalizable to the number of trials, number of possible outcomes per trial, and the length of the repeated sequence.

I like working on this on my own so if you can just give a little hint or guidance I'd appreciate it very much!

• Well, my instinct would be to let a computer do all the work. To do it by hand, I'd go case by case: suppose a run of 3 starts at the first slot (but does not extend to a run of 4). Count those. Now count runs of 4 that start at the first slot. and so on.Each case is easy enough to count, but there are an annoying number of cases. Should be doable though. – lulu Aug 13 '15 at 4:18
• @lulu: That makes it sound more complicated than it is. If inclusion-exclusion is done systematically, it's often (including in this case) a lot less hassle than one might have thought. – joriki Aug 13 '15 at 4:25
• On reflection, doing it by hand shouldn't be too gruesome. Let's count cases: starting in the first slot you have 3 cases (runs of length 3, 4, 5), starting in the second slot you have 2 cases (length 3 and 4), starting in the third slot you only have length 3. That's only 6 cases. Not so bad. – lulu Aug 13 '15 at 4:27
• @joriki Now I agree with you, having just gone through it. It only took a couple minutes (mostly checking). I must say, though, that I trust my ability to debug a simple code more than I trust my ability to check my accounting! – lulu Aug 13 '15 at 4:47
• – user940 Aug 13 '15 at 13:25

You can do this using inclusion-exclusion. The conditions you want are the three conditions that the first, second or third triple of rolls are all the same. Adding the three counts for each of these conditions being met is straightforward. Then you need to substract the counts for each pair of conditions being met. This is only slightly more involved; you need to take into account that in one case the pair covers all five rolls and in the other two cases it only covers four rolls. Then you need to add the count for all three conditions being met – this is again straightforward.

• Inclusion-exclusion will be unwieldy for large number of throws. A better way (computationally) would be via recurrences. Here it should be just a cubic recurrence. – user21820 Aug 13 '15 at 7:46
• @user21820: True. – joriki Aug 13 '15 at 7:47

(The following does not lead to an immediate generalization.)

Write $T$ for the number appearing $\geq3$ times in a row, $X$ for any number in $\setminus\{T\}$, and $N$ for any number in $$. Then the successful sixtuples are of the form $$T^3XN, \quad X T^3X, \quad NXT^3;\quad T^4X, \quad XT^4;\quad T^5\ .$$ As $T$ can be selected in $6$ ways, $X$ in $5$ ways, and $N$ in $6$ ways we obtain a total of $$6\cdot 5\cdot 6+5\cdot 6\cdot 5+6\cdot 5\cdot 6+6\cdot 5+5\cdot 6+6=576$$ favorable cases, all of them equiprobable. The probability $P$ of a success is therefore given by $$P={576\over 6^5}={2\over27}\ .$$

The probability of getting exactly 3 in a row is obtained by counting the ways to select a number for those three, two numbers for the others (from the remaining five numbers, duplicates allowed) and choosing the start position for the triple, out of the total ways to roll the dice.$$\frac{6\cdot 4^2\cdot 3}{6^5} = \frac{4^2\cdot 3}{6^4} = \frac{25}{423}$$

Then to obtain the probability of at least three in a row, we also consider exactly 4 in a row, and all the same.$$\frac{5^2\cdot 3+5\cdot 2+1}{6^4} = \frac{43}{648}$$

• Where does $4^2$ come from? If the exactly $3$ are in the middle, there are $5^2$ options for the other two numbers, and if not, there are $5\cdot6$. Also, the denominator $6^4$ can't morph into $423$ because it doesn't contain the factor $47$. (Also note that the OP had asked for hints or guidance, not for a complete calculation.) – joriki Aug 13 '15 at 4:58
• This is still full of errors. In the first equation, both $4^2$ are probably intended as $5^2$, and $423$ should be $432$. More substantially, though, your edit didn't take into account what I wrote above: There are $5^2$ options only if the exactly $3$ are in the middle; otherwise there are $5\cdot6$ options, since the roll not adjacent to the exactly $3$ isn't constrained. – joriki Aug 13 '15 at 10:24