# Dice Probability

If you have x dice with y sides each, the total of the dice roll can be anywhere from x to x*y. My question is, how do you calculate the probability of rolling a specific number?

I’m no maths guru, but I’d just work out the probability of not getting a specific number, and subtract this from 1.

So - on one die with y sides, the probability of not getting your particular number is:

p = [y-1]/y

(i.e. 5/6 for a 6 sided die)

The probability of not getting your number when throwing two dice (or one die twice) is thus

p = [y-1]/y * [y-1]/y = ( [y-1]/y] )^2

(i.e. 25/36 for teo 6 sided dice)

And thus for x dice:

p = ( [y-1]/y )^x

So, the probability of getting a specific number must be:

p = 1 - ( [y-1]/y )^x

(i.e. around 2/3 chance of throwing a single 6 when rolling six 6-sided dice)

…I think.

No, that’s not quite what I’m talking about.

Say you roll 2d6. The total of this dice roll can be anything from 2 to 12. The following permutations are available:

11 = 2
12 21 = 3
13 22 31 = 4
14 23 32 41 = 5
15 24 33 42 51 = 6
16 25 34 43 52 61 = 7
26 35 44 53 62 = 8
36 45 54 63 = 9
46 55 64 = 10
56 65 = 11
66 = 12

So, the probability of rolling a 2 on 2d6 is 1/36, while the probability of rolling a 7 is 6/36. What I want to know is a formula that can be used to generalize this result for any number of dice with any number of sides.

Well you’ve got x dice with y sides each. That x * y possible combinations.

So if you work out the number of ways to get your number (remembering the ordering is important) and call this C.

Then the probability of getting the number C is C/(x*y).

I think. I’ll see if I can think of a fast way to find the C part.

SD

Dice Probablility? Is s/he related to me somehow?

(sorry, couldn’t reseist :D)

Which is, of course, nonsense. There’s y ^ x combinations.

Ah, I misunderstood. That’s a bit embarrassing…

Still, SpaceDog has the method, but I don’t know off hand what the general formula for working out what the “C” is. Hopefully some smart Doper can come on and tell us, saving anyone the hassle of working it out from scratch.

sirjamesp has answered the question: what is the probability that at least one die shows the number n, where 1 [symbol]£[/symbol] n [symbol]£[/symbol] y. But this is not how I interpreted your question. I shall attempt to answer the question: What is the probability that the sum of the scores on the dice is m, where x [symbol]£[/symbol] m [symbol]£[/symbol] xy.
Let the score on the ith die be X[sub]i[/sub]. Then the total score is
X = X[sub]i[/sub]+ … + X[sub]x[/sub]
The probability generating function ( pgf) for X[sub]i[/sub] is
G(t) = ( t + t[sup]2[/sup] + … + t[sup]y[/sup])/y
= t( 1 - t[sup]y[/sup])/y( 1 - t)
Since the X[sub]i[/sub] are independent, the pgf of X is the product of these, namely
t[sup]x[/sup]( 1 - t[sup]y[/sup])[sup]x[/sup]/y[sup]x[/sup]( 1 - t)[sup]x[/sup]

The rquired probability is the coefficient of t[sup]m[/sup] in this expression, namely the coefficient of t[sup]m-x[/sup] in
( 1 - t[sup]y[/sup])[sup]x[/sup]/y[sup]x[/sup]( 1 - t)[sup]x[/sup]

We need to expand the expressions in the numerator and denominator of this fraction. Let C(n,r) denote the binomial coefficient. Then
( 1 - t[sup]y[/sup])[sup]x[/sup] = 1 - C(x,1)t[sup]y[/sup] + C(x,2)t[sup]2y[/sup] - … + (-1)[sup]x[/sup]t[sup]xy[/sup]
and
( 1 - t)[sup]-x[/sup] = 1 + C(x,1)t + C(x+1,2)t[sup]2[/sup] + …

To get a term t[sup]m-x[/sup] we need a term t[sup]ky[/sup] from the first expression and a term t[sup]m-x-ky[/sup] from the second. The coefficient of this product is (-1)[sup]k[/sup]C(x,k)C(m-ky-1,m-x-ky). The required probability is thus
{C(m-1,m-x) - C(x,1)C(m-y-1,m-x-y) + C(x,2)C(m-2y-1,m-x-2y) - …}/y[sup]x[/sup]
where the sum continues as long as all the binomial coefficients are defined.