I'm trying to find a general method for working out the probability of a score from rolling several dice with varying sides.

For example, the probability of getting a result of 12 when rolling two six-sided dice and three 100-sided dice.

I'm a programmer looking to use this formula for a function, so please be gentle. Thanks!

  • It is kind of ugly. One can get a general approach using generating functions, but for a problem of any complexity we need a good algorithm for computing coefficients. – André Nicolas Sep 13 '14 at 5:59
  • @AndréNicolas Could you point in the direction of the generating functions? They might be sufficient. – cyrus Sep 13 '14 at 7:10
  • I don't know of a good source on the programming side. Wilf's book generatingfunctionology is good, and the earlier edition is freely downloadable. I hope someone will see this comment and improve on my suggestion. Perhaps you could ask a question explicitly (but maybe not at this relatively unpopular time). – André Nicolas Sep 13 '14 at 7:18
  • A very naive and certainly not optimal method would be loop over all partitions of your result which have as many elements as different facing dice are involved and then adding up the probabilities that each of these elements is scored by rolling a number of dice with the same face. For the example you gave: There are 2 different faces (six-sided and 100-sided), giving the partitions $\{\{1\},\{11\}\}$, $\{\{2\},\{10\}\}$ etc. Then you add the probabilities that you roll $1$ with the six sided dice, $11$ with the $100$-sided dice and vice versa, doing this for all partitions. – herrsimon Sep 13 '14 at 10:33

I found a solution to this specific problem by treating each dice roll as a one-dimensional array containing the probability distribution, and then convolving the arrays into a single distribution.

I've uploaded a demonstration here.

  • I described an approach in Excel in this answer That one had all the dice the same, but the same approach would work. You would have to write a sum formula for each type of die, then do the proper copies. A program could be more general, taking an array of the number of sides of each die. – Ross Millikan Sep 14 '14 at 2:45

Try to manipulate a generating function that represent the dice that you want following the example on this link.

For your example the generating function will be

$$f(x)=(x+x^2+\cdots+x^{D_\alpha})^{n_\alpha}\cdot(x+x^2+\cdots+x^{D_\beta})^{n_\beta}\cdots(x+x^2+\cdots+x^{D_\omega})^{n_\omega}$$

where $D_i$ is the number of sides of the dice and $n_i$ is the number of dice of each type rolled. This is for homogeneous and fair dice from 1 to D, for other type of dice you must change the function.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.