I'm searching for an answer to the above problem - how to calculate the probability of getting 3 or more sequential numbers on n number of dice.
I found this formula for 6 six-sided dice here (What are the odds of rolling a 3 number straight throwing 6d6) :
$$ 6^n - 6\cdot4^n + 8\cdot3^n - 3\cdot 2^n \over 6^n $$ However, I can't wrap my head around how to convert this if the die type were changed from d6 to d4s, d8s, or d10s.
Any help would be massively appreciated! Thanking you kindly for taking the time to read this.
Icepool
My Icepool Python package can do this computation:
You can try it online here.
You can even mix standard die types if you wish. The algorithm is based on representing the evaluation of the roll (in this case, finding the largest straight) as a series of state transitions over the (outcome, count) pairs resulting from the roll of the pool:
and then using the decomposition of the multinomial as a product of binomials and dynamic programming to find the distribution efficiently. If you are curious to learn more, you can read my paper here.
More examples
You can find the largest count of any outcome, aka largest matching set, aka best X-of-a-kind, by using
largest_count():You can only consider dice that rolled certain outcomes by inserting
keep_outcomes()ordrop_outcomes(), which accept either a function or a collection of outcomes. You can put any evaluation (largest_count(),largest_straight(), etc.) that you want at the end. For example, these drop all 1-5s from the pool:If you want to only filter some of the dice, you can combine multiple pools using the
+operator. For example, this combines a pool of 2d6 where only 6s are kept with a pool of 3d8 where everything is kept: