3

Background: For those who don't know, exploding dice refers to when you roll the maximum on a die and reroll, cumulatively adding the rolled values until you don't roll the maximum anymore.

Problem: I am trying to find the probability of rolling a value $x$ when rolling 2d10, where each d10 can explode. I have already come up with an equation to calculate the probability of rolling a value on a single n-sided die: $$P\left(x\right)=\left(\frac{\left(\frac{x}{n}-\lfloor(\frac{x}{n})\right\rfloor)}{\left\{x-\lfloor(\frac{x}{n})\rfloor\cdot n=0:1, x-\lfloor(\frac{x}{n})\rfloor\cdot n\right\}}\right)^{\left(1+\lfloor(\frac{x}{n})\rfloor\right)}$$ where $x$ is the expected value, and $n$ is the number of sides on the die.

Is there a way I can use the equation I already have that I'm unaware of to calculate the probability of value $x$ with 2 exploding dice?

  • You can write $\lfloor x \rfloor$ using \lfloor and \rfloor. – Suzu Hirose Jun 16 '22 at 00:06
  • May I know what the denominator notation $\left{x-\operatorname{floor}\left(\frac{x}{n}\right)\cdot n=0:1, x-\operatorname{floor}\left(\frac{x}{n}\right)\cdot n\right}$ mean? – peterwhy Jun 16 '22 at 00:10
  • Thanks for the suggestion @SuzuHirose – Ben Craven Jun 16 '22 at 00:12
  • @peterwhy This is more-or-less a conditional statement using a piecewise function. $x-\lfloor(\frac{x}{n})\rfloor\cdot n=0:1$ means that if the statement $x-\lfloor(\frac{x}{n})\rfloor\cdot n$ evaluates to 0, return 1. Otherwise, return the function's evaluation – Ben Craven Jun 16 '22 at 00:21
  • 1
    @BenCraven I see, I am more familiar with the ternary ?: operator, but outside this maths site. – peterwhy Jun 16 '22 at 00:26

1 Answers1

2

First, I would rewrite the probability mass function for one die as:

$$ \begin{align*} p_1(x) &= \begin{cases} \left(\dfrac1n\right)^{1+\left\lfloor x/n\right\rfloor}&(x\ge0) \wedge (x\bmod n > 0)\\ 0&\text{otherwise} \end{cases}\\ &= \begin{cases} \left(\dfrac1n\right)^{\left\lceil x/n\right\rceil}&(x\ge0) \wedge (x\bmod n > 0)\\ 0&\text{otherwise} \end{cases} \end{align*}$$

Then for two independent dice, the sum $x$ follows the probabilities:

$$p_2(x) = \sum_{i=-\infty}^{\infty} p_1(i) p_1(x-i) = \sum_{i=0}^{x} p_1(i) p_1(x-i)$$

Assuming $x\ge0$, splitting into cases of $x\bmod n$:

  • if $x\bmod n = 0$, i.e. $x=kn$ for some $k$, then:

    $$\begin{align*} p_2(x) &= \sum_{i=1}^{n-1} \left(\frac1n\right)^{1}\left(\frac1n\right)^{k} + \sum_{i=n+1}^{2n-1} \left(\frac1n\right)^{2}\left(\frac1n\right)^{k-1}+\cdots+ \sum_{i=x-n+1}^{x-1} \left(\frac1n\right)^{k}\left(\frac1n\right)^{1} \\ &= \frac xn (n-1) \left(\frac1n\right)^{x/n+1} \end{align*}$$

  • if $x\bmod n > 0$, then let $r=x\bmod n$, and so $x = kn+r$:

    $$\begin{align*} p_2(x) &= \sum_{i=1}^{r-1} \left(\frac1n\right)^{1}\left(\frac1n\right)^{k+1} + \sum_{i=r+1}^{n-1} \left(\frac1n\right)^{1}\left(\frac1n\right)^{k}\\ &\quad +\sum_{i=n+1}^{n+r-1} \left(\frac1n\right)^{2}\left(\frac1n\right)^{k} + \sum_{i=n+r+1}^{2n-1} \left(\frac1n\right)^{2}\left(\frac1n\right)^{k-1} + \cdots\\ &\quad +\sum_{i=kn+1}^{x-1} \left(\frac1n\right)^{k+1}\left(\frac1n\right)^{1}\\ &= \left(k+1\right)(r-1)\left(\frac1n\right)^{k+2} + k(n-r-1)\left(\frac1n\right)^{k+1}\\ &= \left\lceil\frac xn\right\rceil [(x\bmod n)-1]\left(\frac1n\right)^{\left\lceil x/n\right\rceil+1} + \left\lfloor\frac xn\right\rfloor [n-(x\bmod n)-1]\left(\frac1n\right)^{\left\lfloor x/n\right\rfloor+1}\\ \end{align*}$$

Or merging the two cases if the following looks better:

$$\begin{align*} p_2(x) &= \left\lceil\frac xn\right\rceil \max\left[0,\frac{(x\bmod n)-1}n\right]\left(\frac1n\right)^{\left\lceil x/n\right\rceil}\\ &\quad + \left\lfloor\frac xn\right\rfloor \left[1-\frac{(x\bmod n)+1}n\right]\left(\frac1n\right)^{\left\lfloor x/n\right\rfloor}\\ \end{align*}$$

peterwhy
  • 22,256