What is the probability of rolling X specific numbers on Y six-sided dice?

3.6k Views Asked by At

I am writing the AI for a dice game and I have hit a mental block.

I need to know the probability of rolling $X$ specific numbers on Y six-sided dice, where $Y \leq 6$ and $X < Y$ (otherwise the probability would obviously be 0!)

E.g. What is the probability of rolling a 2 and a 4 with 5 dice.

I know that the number of total rolls is $6^Y$ so the answer must be something like...

$f(x,y)/(6^Y)$

Any suggestions?

Thanks in advance!

3

There are 3 best solutions below

5
On BEST ANSWER

The probability of rolling at least one from $X$ specified numbers when given $Y$ rolls of a cubic die is the probability of not rolling none of them.

$$f_{X\mid Y}(x\mid y) ~=~ 1-\left(\frac{6-x}{6}\right)^y\qquad\Big[x\in \Bbb N,y\in \Bbb N,1\leq x\leq \min\{y, 6\}\Big]$$

The probability of rolling $X$ specific number at least once each, when given $Y$ rolls of a cubic die is, the probability of not missing any of them.

$$g_{X\mid Y}(x\mid y) ~=~ 1-\sum_{k=0}^x \binom 6{x-k}(-1)^k \left(\frac{6-x+k}{6}\right)^y\qquad\Big[x\in \Bbb N,y\in \Bbb N,1\leq x\leq \min\{y, 6\}\Big]$$

4
On

If you roll $5$ six-sided dice, there are $5^5$ ways not to roll a two, $5^5$ ways not to roll a four, and $4^5$ ways to roll neither a two nor a four. By inclusion-exclusion, the number of obtaining at least one two and at least one four when rolling $5$ dice is

$$6^5-5^5-5^5+4^5$$

1
On

From my understanding of your setup, you are rolling $Y$ dice, each with $n$ numbered sides, and wish to calculate the probability of getting a set of $X$ distinct numbers at least once each.

$$\{a_1,a_2,...,a_X\},\ X\le\min(n,Y)$$

In order to calculate the probability, we need to count the number of rolls that satisfy this condition. It is actually more convenient to consider the rolls that do not.

The number of rolls in which $a_1$ does not appear at all is $(n-1)^Y$, and likewise for all the other values. We then simply need to compute the number for which at least one of these numbers does not appear, which is to say, which is to say, the union of the set of rolls for which one $a_i$ does not appear. This calls for the use of the Inclusion Exclusion Principle.

To obtain the cardinality of the union, we simply take the sum of the cardinalities of each individual set, minus the sum of the cardinalities of the intersections of all the pairs of sets, plus the cardinalities of the intersections of all groups of 3 sets, and so on. If we assume the numbers are distinct, the intersection of $m$ sets has cardinality $(n-m)^Y$, since it is the number of rolls in which neither of 2 distinct numbers appear. Also there are $\binom Xm$ possible groupings of $m$ sets. combining these and applying Inclusion-Exclusion, we obtain the number of rolls for which at least one $a_i$ does not appear:

$$(n-1)^Y-\binom X2(n-2)^Y+\binom X3(n-3)^Y+...=\sum_{i=1}^{X}(-1)^{i+1}\binom Xi(n-i)^Y$$

To obtain the number of rolls that do meet the criteria, we simply subtract this value from $n^Y$, the total number of rolls, yielding a compact result.

$$\sum_{i=0}^{X}(-1)^{i}\binom Xi(n-i)^Y$$

Since each individual roll is equally likely, the probability is just this value divided by the total number of rolls:

$$p=\frac 1{n^Y}\sum_{i=0}^{X}(-1)^{i}\binom Xi(n-i)^Y$$