# Probability Mass Function of infinitely re-rolled dice

I play a game called Shadowrun. It is a role-playing game that uses a dice pool mechanic. A player has a dice pool of $$x$$ six-sided, unbiased dice. Every 5 or 6 counts as a success. The more successes, the better. Calculating this probability is easy (it's a simple binomial distribution with number of trials $$n = x$$ and probability of success $$p = \frac{1}{3}$$).

However, every player has an additional attribute called Edge, $$y$$. Edge can be used in one of two ways:

a) It allows a player to take all the dice that didn't roll a success in the first attempt and roll them again. Any successes achieved this way add to the result.

b) It allows a player to add their Edge to the total number of dice they roll and any dice that rolled a 6 can be rolled again and if they roll a success, that adds to the result; if any of the dice rolled a 6 again, they can be rerolled. This can be done until the dice no longer roll a six. This is called "exploding dice".

The player can only do one or the other, not both and they can use this ability a limited number of times per game.

My question is: which one is better, given a pool of $$x$$ and Edge $$y$$ - or more precisely - is there a simple way of expressing the probability mass function of method B? I have found a simple function for method A and a long, computationally intensive one for method B, but I wonder if there is a way of simplifying it. Below is my work so far.

Thanks for your help and I apologise if this question has been asked before (I looked, I could find things regarding exploding and adding the result, but not just adding 1 to the successes with infinite explosions) and sorry if I'm breaking unwritten community rules - it is my first post here.

# A. The Reroll

The first method is to reroll the dice that failed on the first try. This means the methods of achieving a success are:

• Roll a 5 or 6 (probability $$\frac{1}{3}$$)
• Roll a 1, 2, 3, 4 (probability $$\frac{2}{3}$$) and then reroll to a 5 or 6 (probability $$\frac{1}{3}$$) Therefore the probability of succeeding on a single dice roll is: $$p = \frac{1}{3} + \frac{2}{3} \cdot \frac{1}{3} = \frac{5}{9}$$ This leads to a binomial distribution: $$Pr(X = s) = \binom{x}{s} \left(\frac{5}{9}\right)^s \left(\frac{4}{9}\right)^{x-s}$$ Where $$x$$ is the dice pool and $$s$$ is the desired number of successes.

# B. The Exploding Dice

For this part I am going to simplify my notation a bit. I am going to use a subscript to indicate the number of dice rolled and I am going to ommit the $$X =$$ part in the probability function, e.g. $$Pr_7(4)$$ is the probability of achieving 4 successes on 7 dice. I will be using $$s$$ to denote a number of successes

## 1 die

I didn't have a clear idea how to approach this, so I started with a single die. In order to achieve:

• 0 successes: the roll must be 1-4
• 1 success: the roll must be 5 or a 6 followed by a 1-4
• 2 successes: the roll must be 6 followed by a ,5 or followed by a 6 followed by a 1-4 I can note that as: $$Pr_1(0) = \frac{2}{3}$$ $$Pr_1(1) = \frac{1}{6} + \frac{1}{6} \cdot \frac{2}{3} = \frac{1}{6} \cdot \frac{5}{3}$$ $$Pr_1(2) = \frac{1}{6} \cdot \frac{1}{6} + \frac{1}{6} \cdot \frac{1}{6} \cdot \frac{2}{3} = \left(\frac{1}{6}\right)^2 \cdot \frac{5}{3}$$ $$Pr_1(s) = \left(\frac{1}{6}\right)^s \cdot \frac{5}{3} \quad for \; s > 0$$

## 2 dice

So here my approach was similar, using combinations:

• 0 successes: the number of successes must be 0 on Dice 1 and 0 on Dice 2
• 1 success: the number of successes must be 1 on Dice 1 and 0 on Dice 2; or 0 on Dice 1 and 1 on Dice 2
• 2 successes: the number of successes must be 2 on Dice 1 and 0 on Dice 2; or 1 on Dice 1 and 1 on Dice 2; or 0 on Dice 1 and 2 on Dice 2

Similarly, I can note this using the previously calculated one-die probabilities: $$Pr_2(0) = Pr_1(0)Pr_1(0)$$ $$Pr_2(1) = Pr_1(1)Pr_1(0) + Pr_1(0)Pr_1(1)$$ $$Pr_2(2) = Pr_1(2)Pr_1(0) + Pr_1(1)Pr_1(1) + Pr_1(0)Pr_1(2)$$ $$Pr_2(s) = \sum_{n=0}^{s} Pr_1(s-n)Pr_1(n)$$

## 3 dice

I am going to spare you the repeat - this time I need to iterate through three dice, which I can write as: $$Pr_3(s) = \sum_{m=0}^{s-n}\sum_{n=0}^{s} Pr_1(s-n-m)Pr_1(n)Pr_1(m)$$

## Any pool

So techinically, for $$x + y$$ dice (remembering that we add the Edge to the pool in method B) I can write an extremely cumbersome formula that basically iterates through all the possible combinations of parameters and uses single-die probabilities to calculate the total probability. The problem is that for pools even as small as 10 dice, this is thousands of possible combinations and just seems a bit brute-force-y. Does anybody have any idea how to simplify this. For completeness, I am attaching the formula:

$$Pr_{x+y}(s)= \sum_{n_{1}=0}^{s} \sum_{n_{2}=0}^{s - n_{1}} \sum_{n_{3}=0}^{s - n_{1} - n_{2}} \cdots \sum_{n_{x+y}=0}^{s - \sum_{a=1}^{x+y-1} n_a} \left[Pr_1\left(s- \sum_{b=1}^{x+y} n_b\right) \cdot \prod_{c=1}^{x+y} Pr_1(c) \right]$$

• What a great username for a SR question! Just to make sure I got all the parameters: Given a pool $x$ and edge $y$, and a desired number of successes $s$, we want to determine if method A (having an option on a reroll) or method B (adding edge to your pool and having explosive dice) has the higher probability to get at least $s$ successes? Would some kind of simulation satisfy you? Commented May 27, 2016 at 17:18
• Yes, that is correct. Technically I have a method, but it requires a huge amount of computation for larger pools, so I'm looking for something simpler. Commented May 27, 2016 at 17:19
• "It allows a player to add their Edge to the total number of dice they roll." I'm not sure I understand this. It reads like if Edge $= y$, then the player rolls $x+y$ dice instead of $x$ dice (and then the successful dice all explode in the manner described above). Is that right? Can you clarify if not? Commented May 27, 2016 at 17:22
• You are correct. Commented May 27, 2016 at 17:25
• For method A, the current formula is assuming that you are going to use the reroll action every time - but you only have to use it if you don't hit at least $s$ successes. Since the use of edge is a limited resource, this could also be reflected somehow. Commented May 27, 2016 at 17:46

Scenario $B$ is equivalent to a scenario where each die has success probability $\frac23$ on the first roll and $\frac16$ on all further rolls, and is rerolled as long as it succeeds. We can use this to express the distribution as a single convolution, instead of the $(x+y)$-fold convolution that you wrote.

The probability for $k$ of $m=x+y$ dice to succeed on the first roll is

$$\binom mk\left(\frac13\right)^k\left(\frac23\right)^{m-k}\;.$$

In the second part of the experiment, instead of rerolling $k$ dice we can imagine the same die being rerolled until it has failed $k$ times. The probability for this to happen after $s$ additional rolls, yielding $s-k$ additional successes, is

$$\binom{s-1}{k-1}\left(\frac56\right)^k\left(\frac16\right)^{s-k}\;.$$

Thus, the probability for a total of $s$ successes is

$$\sum_{k=0}^s\binom mk\left(\frac13\right)^k\left(\frac23\right)^{m-k}\binom{s-1}{k-1}\left(\frac56\right)^k\left(\frac16\right)^{s-k}\\ =\left(\frac23\right)^m\left(\frac16\right)^s\sum_{k=0}^s\binom mk\binom{s-1}{k-1}\left(\frac52\right)^k\;.$$

• ...so in order to get the probability to get at least $S$ successes, one needs to sum the last expression from $s$ to $\infty$, correct? Commented May 28, 2016 at 9:37
• This answer seems to overlook parts of OP's problem. First of all, rolling a 5 or a 6 always counts as 1 success, no matter if it's after the initial roll or not. So [...] where each die has success probability 2/3 on the first roll and 1/6 on all further rolls is not true. Scenario B is equivalent to a scenario where each die always has a success chance of 1/3 (not 2/3) and a 1/6 chance to add another die to the pool to follow these same rules For instance I have 4 dice, I roll 6 6 5 3, reroll the two 6s I get 6 5, reroll the one 6 again to a 5 : This roll yielded 6 success : 6 6 5 6 5 5 Commented Oct 10, 2018 at 17:38
• Thus, the following part is also not correct. You don't get one reroll per success, and so you can't equate additionnal successes = k = rerolled successes at 1/6 chance. But, your answer might be completed by adding those non-rerollable successes on top of the formula, it simply is an additionnal 1/6 chance per reroll to have a "normal" success. Commented Oct 10, 2018 at 17:40

Having done a bunch of work on these types of distribution recently, I think I can give this a rigorous shot with the help of probability generation functions.

## Why PGFs?

The question asked here is: Which option is better, given $$x$$ dice and $$y$$ edge, which I think we can reasonably assume means "which option gives a higher expectation of successes?". So, we don't actually need to find a mass function for these rolls - we just need to find a way to calculate the expectation in terms of $$x$$ and $$y$$, and once we have a generating function, finding the expectation is incredibly simple.

The Base Function Because we're dealing with a binomial distribution, our base function is incredibly simple. If we represent successes with $$z$$, we can use:

$$[F(z)]^x=\left(\frac{2z}{6}+\frac{4}{6}\right)^x$$

We simply replace $$x$$ with the number of dice we're rolling, and once we've expanded it out, the coefficient of each power of $$z$$ will be the probability of getting that many successes (so the coefficient of $$z^1$$ will be the probability of 1 success, the coefficient of $$z^2$$ will be the probability of 2 successes, and so forth. Even better, if we want to find it's expectation, we simply differentiate the function once with respect to $$z$$, and then set $$z=1$$. If we do that here, we get:

$$E(X)=\frac{2x}{6}$$

## Option 1: Reroll Failures

Re-reading the rules for Edge use in Shadowrun, the rules state that a player can only spend one edge per roll. If we follow that rule, rerolling failures is easy to represent as a Generating Function, by simply multiplying the probability of failure by the original generating function and so we get:

\begin{align*} [F(z)]^x&=\left(\frac{2z}{6}+\frac{4}{6}\left(\frac{2z}{6}+\frac{4}{6}\right)\right)^x\\ &=\left ( \frac{5z}{9}+\frac{4}{9} \right )^x \end{align*}

And again, we can differentiate once with respect to $$z$$ than set $$z=1$$ to get:

$$E(X)=\frac{5x}{9}$$

## Option 2: Extra Dice + Exploding Dice

This is where the Generating function approach benefits us greatly. Since our function effectively represents rolling a single die, we can use a recursive approach to define our exploding dice generating function. Starting with a single dice:

$$F(z)=\frac{z}{6}+\frac{4}{6}+\frac{zF(z)}{6}$$

We can then do some simple algebra to solve for \$F(z):

\begin{align*} F(z)&=\frac{z}{6}+\frac{4}{6}+\frac{zF(z)}{6} \\ 6F(z)&=z+4+zF(z)\\ 6F(z)-zF(z)&=z+4\\ F(z)(6-z)&=z+4\\ F(z)&=\frac{z+4}{6-z}\\ [F(z)]^{x+y}&=\left (\frac{z+4}{6-z} \right )^{x+y}\\ \end{align*}

Since we add our Edge in dice as well, we add our dice and Edge together to set the exponent. This is all perfectly differentiable with respect to $$z$$, so if we do and set $$z=1$$, we get:

$$E(X)=\frac{2(x+y)}{5}$$

## Comparing the Pair

So we have our two expectations that we can easily compare. We can see that if we set $$y$$ to zero and compare the two expectations, we get $$\frac{5x}{9} = 0.555...$$ per dice for the first, and $$\frac{4x}{10} = 0.4$$ per dice for the second. Since each point in Edge gives us an extra dice, each extra Edge point effectively adds $$0.4$$ to our expectation. As a simple table:

x y E(Opt1) E(Opt2)
1 0 0.555... 0.4
1 1 0.555... 0.8
1 2 0.555... 1.2
1 3 0.555... 1.6
1 4 0.555... 2
1 5 0.555... 2.4
5 0 2.777... 2
5 1 2.777... 2.4
5 2 2.777... 2.8
5 3 2.777... 3.2
5 4 2.777... 3.6
5 5 2.777... 4
10 0 5.555... 4
10 1 5.555... 4.4
10 2 5.555... 4.8
10 3 5.555... 5.2
10 4 5.555... 5.6
10 5 5.555... 6

So, if $$x$$ is low, and $$y$$ is high, adding dice + explosions is generally the better option, while the higher $$x$$ is, the higher $$y$$ needs to be in order for adding dice + explosions to return a better result than rerolling successes.

## Also, Mass Functions!

Since the question did ask for Mass Functions as well, we might as well get them done as well. The first option for probability $$k$$, as noted, very simple:

$$P(K=k)=\binom{x}{k}\left( \frac{20}{36} \right)^k\left( \frac{16}{36} \right)^{x-k}$$

The second option is a little more complicated, but we can adapt the mass function from this answer to come up with:

$$P(K=k)=\sum_{i=0}^{\min(k,x+y)}\binom{x+y}{i}\binom{x+y+k-i-1}{k-i}\left( \frac{1}{6} \right)^i\left( \frac{1}{6} \right)^{k-i}\left( \frac{4}{6} \right)^{x+y-i}$$

Since our exploding probability and our normal success probability are identical, we can do some simplification to end up with:

$$P(K=k)=\sum_{i=0}^{\min(k,x+y)}\binom{x+y}{i}\binom{x+y+k-i-1}{k-i}\left( \frac{1}{6} \right)^k\left( \frac{4}{6} \right)^{x+y-i}$$