Given d dice each with n sides, find the probability that when they are rolled at once, there are no two consecutive numbers.
This task may be quite difficult. For a warm-up, try finding the numerators for fixed d such as {1,2,3} or for fixed n such as {2,3,4}.
Note 1: I don't have a formula so much as an algorithm.
Note 2: This problem arose as an attempt to solve http://perplexus.info/show.php?pid=12342 by Larry which uses non-independent cards instead of dice.
For d dice each with n sides, the probablity of no consecutives is a numerator over a denominator. In the case of a single die, it's impossible to have consecutives, so the probability of no consecutives is 1. For d=1, a single die, the numerator and denominator are both n.
So far, I've worked out the pattern for the denominator:
For d=2, the denominator is the n-th triangular number.
For d=3, the denominator is the sum of the first n triangular numbers.
For d=4, the denominator is the sum of the sum of the first n triangular numbers.
etc.
I don't have a pattern for the numerators yet.
---
Below is a Python function to compute the desired probablility for d dice each with n sides.
---
from itertools import combinations_with_replacement
def isConsec(aList):
sList = sorted(aList)
for ind,num in enumerate(sList):
if ind == 0:
continue
if sList[ind] - sList[ind-1] == 1:
return True
return False
def p_no_consec(d,n):
denom = 0
numerator = 0
numbers = [i for i in range(1,n+1)]
for roll in combinations_with_replacement(numbers,d):
lroll = list(roll)
denom += 1
if not isConsec(lroll):
numerator += 1
return [numerator, denom, numerator/denom]
|
Posted by Larry
on 2021-01-26 09:08:39 |