1

Using dice notation to denote the total (i.e. xdy means the total of x dice with y sides) my question would be finding the probability of the following statement to be true (I am not sure if there is a better way of representing this) -

$ \sum\limits_{i=1}^n{c_i\text{d}i} = p$

where $c_i\in \mathbb{Z^+_0}$

I learnt how to do this for one kind of dice here, here and here. I was wondering about an even more general case where all the dice being rolled are not the same. I tried following a similar approach to this one of making n bins and then distributing a total of p balls into these bins, with each bin being equal to $c_i$ dice with $i$ sides. Choosing a number to put into a bin of course would depend on the probability of getting that total from this group of dice with the same number of sides. The minimum in each bin corresponds to $c_i$, and thus we are left with the problem of putting $\left(p-\sum\limits_{i=1}^nc_i\right)$ balls into n bins.

I am a bit confused as to how to proceed from here, since adding another ball in all of these bins will change the probability differently. I couldn't find any resources specifically answering this question anywhere either.

Thomas Andrews
  • 177,126
Yuki.kuroshita
  • 173
  • 1
  • 9
  • 1
    The general question is hard. You can solve it in individual cases using generating functions, where you want the coefficient of $x^p$ in $$\prod_{i}\left(\frac{x-x^{i+1}}{1-x}\right)^{c_i}=\dfrac{\prod_{i}(x-x^{i+1})^{c_i}}{(1-x)^{\sum_i c_i}}$$ – Thomas Andrews Nov 05 '22 at 02:45
  • If you expand the numerator as $\sum a_kx^k$ and let $c=\sum_{i} c_i,$ the total number of dice, then you get the coefficient of $x^p$ is $$\sum_k a_k\binom{p+c-1-k}{c-1}$$ So you can find the $a_k,$ but a general formula for the $a_k$ in terms of $c_i$ will be hard. And there can be a lot of constants $a_k.$ – Thomas Andrews Nov 05 '22 at 02:51
  • For example, when $c_6=2, c_4=2$ and all other $c_i=0,$ then $$\sum a_kx^k=x^4(1-x^6)^2(1-x^4)^2=x^4(1-2x^4-2x^6+x^8+4x^{10}+x^{12}-2x^{14}-2x^{16}+x^{20})$$ and you get: $$\binom{p-1}{3}-2\binom{p-5}{3}-2\binom{p-7}{3}+\binom{p-9}{3}+4\binom{p-11}3+\cdots$$ (9 terms) – Thomas Andrews Nov 05 '22 at 03:08
  • A small partial answer, but from a generating function perspective, if you have $n$ dice with $c_1, c_2, \cdots c_n$ sides, the generating function is

    $$\prod_{i=1}^n \left( \sum_{j=1}^{c_i} x^i \right)$$

    Similar but not quite the same as what @ThomasAndrews wrote in the above comments. Essentially each die is $(x+x^2+\cdots+x^c)$, and you multiply all the dice together, which will give you the coefficients. --- Also, while it doesn't answer the question, http://www.anydice.com could be helpful for playing around with things.

    – Eric Snyder Nov 05 '22 at 03:16
  • $c_i$ is the number of dice with $i$ sides, so your formula should be different, @EricSnyder. It should be $$\prod_i. \left(\sum_{j=1}^i x^j\right)^{c^i}$$ – Thomas Andrews Nov 05 '22 at 03:19
  • To, um, "expand" a bit, the coefficients from that multiplication give you the number of ways of rolling a total of $q$, where $q$ is each exponent. So for 2d6, expanding the multiplication will give $(x+x^2+x^3+x^4+x^5+x^6)^2 = x^2+2x^3+3x^4+\cdots+6x^7+\cdots+2x^{11}+x^{12}$, the RHS being the familiar set of numbers we get for the possible ways of rolling $2$ through $12$ on 2d6. – Eric Snyder Nov 05 '22 at 03:27
  • @ThomasAndrews Oh, whoops! I see what you mean, I didn't quite pick up on OP's terminology. – Eric Snyder Nov 05 '22 at 03:29
  • @ThomasAndrews I have a couple of questions. First, could you explain how you got that generating function? Second, why are we only expanding the numerator (instead of the whole thing) as a power series? And lastly, in your example, why is there no $x^5$ term (there are obviously other things that don't add up in my understanding)? I am guessing that is because of the denominator? – Yuki.kuroshita Nov 05 '22 at 06:57
  • @EricSnyder The generating function makes sense to me, but is there any analytical way to get the coefficients? I do know of anydice.com (I started thinking of this problem when I was using said website to calculate potential damage for a dungeons & dragons character) and I have even written some code to roll dice millions of times to get me the probability of given ranges of $c_i$ and then fit them with a gaussian and try to find a trend for the mean and standard deviation. It is a bit too convoluted so I was wondering if there is an analytical method. – Yuki.kuroshita Nov 05 '22 at 07:08
  • Thomas's comments above have some of what you need... I recommend hitting up Google or Approach0 with "extract coefficients from generating function", which turned up, for example, https://math.stackexchange.com/questions/992125/if-i-roll-three-dice-at-the-same-time-how-many-ways-the-sides-can-sum-up-to-13/993044#993044, as well as a bunch of other similar links. – Eric Snyder Nov 05 '22 at 21:02

0 Answers0