3
$\begingroup$

I am working on a project that needs to be able to calculate the probability of rolling a given value $k$ given a set of dice, not necessarily all the same size. So for instance, what is the distribution of rolls of a D2 and a D6?

An equivalent question, if this is any easier, is how can you take the mass function of one dice and combine it with the mass function of a second dice to calculate the mass function for the sum of their rolls?

Up to this point I have been using the combinatorics function at the bottom of the probability section of Wikipedia's article on dice, however I cannot see how to generalize this to different sized dice.

  • 0
    Is $D2$ a two sided "dice", i.e a coin and $D6$ a regular dice?2011-02-03
  • 0
    Related, but not exactly dupe: http://math.stackexchange.com/questions/4632/how-can-i-algorithmically-count-the-number-of-ways-n-m-sided-dice-can-add-up-to/2011-02-03
  • 0
    @milcak yes, that is standard notation for dice of different sizes. Sorry if that wasn't obvious.2011-02-03

3 Answers 3

5

You can use generating functions.

I presume D2 means dice with numbers 1 and 2.

In which case the probability generating function is

$$(x/2 + x^2/2)(x/6 + x^2/6 + x^3/6 + x^4/6 + x^5/6 + x^6/6) = \frac{x^2(x^2-1)(x^6 - 1)}{12(x-1)^2}$$

You need to find the coefficient of $x^k$ in this to get the probability that the sum is $k$.

You can use binomial theorem to expand out $\frac{1}{(x-1)^2}$ in the form $\sum_{n=0}^{\infty} a_n x^n$

You can generalized it to any number of dice with varying sides.

I will leave the formula to you.

  • 0
    Could you please elaborate on how you get from the probabilities of the different dice to the expression on the right? I cannot follow that reasoning.2011-02-03
  • 0
    @dimo: It is adding up terms in geometric progression.2011-02-03
  • 0
    Sorry, I'm afraid this is all a bit over head. I'll have to look into this all further. http://static.funnyjunk.com/pictures/twelve_plane_of_torment0.jpg2011-02-03
  • 0
    @Moron: what will it do to expand out $\frac{1}{(x-1)^2}$ in this case? For $x\gt8$ in this case, the probability is 0 anyway...2011-02-03
  • 0
    @QIang: You mean $k \gt 8$? YOu don't have to expand out the whole thing, just upto $x^k$.2011-02-03
  • 0
    @Moron: right, I meant $k\gt 8$. I just do not see the advantage of writing the expression the way you wrote here just for rolling the two dice each once. In addition, $x^2-1$ has a factor $x-1$ that can be canceled with the denominator $(x-1)^2$.2011-02-03
  • 0
    @Qiang: Sure go ahead and cancel it :-) The point is: for cases known before hand, you can just read off a formula! For unknown cases, i.e. say in a computer program, it boils down to multiplying polynomials, which can be done fast using FFT, for instance. Let me ask you this: Say there were 100, 6 sided dice. What are the chances of getting a sum of 367 when you roll them all (order matters)? See this for an answer: http://math.stackexchange.com/questions/4632/. btw, This is a general method and was provided because OP asked for it.2011-02-03
0

For D2+D6, you can only get 2 or 8 in one case each, probability 1/12. Other totals 3-7 you can attain two ways (for example 6=5+1 or 4+2), probability 2/12=1/6. A good check is the total over all the values is 1. The check is 2*(1/12)+(7-3+1)*(1/6)=1

  • 0
    Sorry, maybe I wasn't clear. I'm trying to figure out a general function that works on different sided dice in the same way F(s,n) in the Wikipedia article works.2011-02-03
  • 0
    @Moron: Moron has it right for that. See his answer.2011-02-03
0

Suppose we have dice $Da$ and $Db$, with $a \le b$. Then there are three cases:

  1. If $2 \le n \le a$, the probability of throwing $n$ is $\frac{n-1}{ab}$.
  2. If $a+1 \le n \le b$, the probability of throwing $n$ is $\frac{1}{b}$.
  3. If $b+1 \le n \le a+b$, the probability of throwing $n$ is $\frac{a+b+1-n}{ab}$.