21
\$\begingroup\$

I need at least a 10 on a d20. I can roll until I get it, or I get a 1. What is the chance I succeed? I would like to have the general formula, not just for 10.

The chance of success on the first try is 55% (11/20). If I do not succeed, which has a chance of 40%, I can try again with the same chance, so should be:

$$ 0.55 + 0.4 \times 0.55 + (0.4\times0.55)^2 + {...} + (0.4 \times 0.55)^n $$

Generally (TN = target number)

$$ \frac{21-TN}{20} + \frac{TN-2}{20}\times\frac{21-TN}{20} + {...} $$

But how do I calculate the sum of this?


(The question is very loosely related to Pathfinder 2e, so I left out the tag intentionally. But edgerunner asked, so here it is.

If you have the Trick Magic Item skill feat, you can try to cast a 2nd rank Tailwind from a Magic Wand. It lasts 8 hours, so you can try this before your adventuring day starts. As no one is hurrying you, you can try until you Succeed, or until you Critically Fail, which only happens on a 1 by the time you can afford a 5th level wand. There is no consequence in getting 2-9, other than wasting your turn, which is not an issue outside of combat.)

\$\endgroup\$
1
  • 1
    \$\begingroup\$ I'm curious. Since people have pointed out that the probability of this roll can be reduced to 11/12 on a d12, what's the in-game point of having a reroll mechanic here? Is it an action that does nothing on 2-9 so that others get to act before you can reroll? Is there some other consequence to getting a 2-9? \$\endgroup\$
    – edgerunner
    Commented Feb 7 at 0:09

5 Answers 5

31
\$\begingroup\$

Let's Use the Omnipresent Geometric Series.

The probability to get at least a 10 is 11/20, while the probability to reroll are 8/20: hence the correct formula is $$ P(10^+) = \frac{11}{20} + \frac{8}{20}\frac{11}{20} +\left(\frac{8}{20}\right)^2\frac{11}{20} + \left(\frac{8}{20}\right)^3\frac{11}{20}+... $$ i.e., the probability to get a number greater or equal than 10 at 1st try, plus the probability to get less then 10 (but not 1) at 1st roll and greater or equal than 10 at the second, and so on. This sums up to $$ P(10^+) = \frac{11}{20}\sum_{i=0}^\infty\left(\frac{8}{20}\right)^i = \frac{11}{12}. $$

For a general target t, the formula becomes $$ P(t^+) = \frac{21-t}{20}\sum_{i=0}^\infty\left(\frac{t-2}{20}\right)^i = \frac{21-t}{22-t}. $$

The term in the series is t-2 since one has to consider the number of cases where the roll is less than t and different from one: these are 20-(21-t)-1=t-2.

The following table provides the probabilities for each target in \$\{2,3,\dots,20\}\$ and, for comparison, the simulation results obtained via MatLab.

Target Simulation Theoretical
2 95.01 95.00
3 94.75 94.74
4 94.44 94.44
5 94.11 94.12
6 93.77 93.75
7 93.32 93.33
8 92.85 92.86
9 92.31 92.31
10 91.71 91.67
11 90.92 90.91
12 90.04 90.00
13 88.88 88.89
14 87.42 87.50
15 85.68 85.71
16 83.34 83.33
17 79.95 80.00
18 74.96 75.00
19 66.71 66.67
20 49.97 50.00

An Elegant Solution, without the Geometric Series

Another way to achieve the same formula is given by the beautiful approach of ApexPolenta's answer: the probability of getting a result greater than 10 is $$ P(10^+) = \frac{11}{20} + \frac{8}{20}P(10^+) $$ and solving for \$P(10^+)\$ one obtains again
$$ \begin{eqnarray*} P(10^+) &=& \frac{11}{20} + \frac{8}{20}P(10^+)\\\\ P(10^+) - \frac{8}{20}P(10^+)&=& \frac{11}{20} \\\\ \frac{12}{20}P(10^+)&=& \frac{11}{20} \\\\ P(10^+)&=&\frac{11}{12} \end{eqnarray*}. $$

Generalization to a die with d faces.

A straightforward generalization of the probability of getting at least t, within these rules, with a die with d faces is the following: $$ P(t^+) = \frac{d+1-t}{d+2-t} = \frac{d-(t-1)}{d-(t-1)+1} = \frac{r}{r+1} $$ where r=d-(t-1). Note that r is exactly the successful outcomes, while r+1 is the number of possible cases under the current rules. Hence, the probability is actually independent on the number of faces1.


1Credits to GentlePurpleRain for this clever remark, pointed out in the comments.

\$\endgroup\$
3
  • \$\begingroup\$ You can simplify that final formula even more. Without loss of generalization, you can say that instead of wanting to get a number that is "at least \$t\$", you want to get any number in the set R where the size of R is \$r = d - t + 1\$. (This could be the numbers 4, 17, 23, etc., but the probability is the same.) In the example above, \$r = 20 - 10 + 1= 11\$ (the number of possible rolls that are 10 or higher on a d20). Then \$t = d - r +1\$, and we can substitue that into your formula as \$\frac{d+1-(d-r+1)}{d+2-(d-r+1)}\$, which simplifies to just \$\frac{r}{r+1}\$. \$\endgroup\$ Commented Feb 5 at 20:37
  • \$\begingroup\$ The number of faces on the die is actually irrelevant. Only the number of possible "success" results is important. (If you're trying to get 90 or more on a d100 vs. 10 or more on a d20, the probabilities are exactly the same.) \$\endgroup\$ Commented Feb 5 at 20:38
  • 1
    \$\begingroup\$ @GentlePurpleRain Thanks for this, I added to the answer. Indeed, the difference of just 1 between the terms in the ratio ringed a bell, but I did not pay enough attention. \$\endgroup\$
    – Eddymage
    Commented Feb 5 at 21:21
29
\$\begingroup\$

You don't need to understand series for this

... although examples like this are a great way to gain an understanding of series and/or to prove the formula.

Instead: suppose your probability of success is \$p\$. How will we solve for that?

55% of the time (rolls 10 through 20 inclusive), you know you succeed on the first roll. 5% of the time (on a 1), you know you fail on the first roll. The remaining 40% of the time, the first roll is a 2 through 9 inclusive... and you are right back where you started: your conditional probability of success at this point is \$p\$, just as it was to begin with. You have gained no information.

Therefore, the overall probability of success is \$p = 0.55 \cdot 1 + 0.05 \cdot 0 + 0.40 \cdot p\$, the probability outcomes after the first roll, weighted by the probabilities of those first roll results.

It's simple algebra to solve that by collecting terms: \$0.60 \cdot p = 0.55 \cdot 1 + 0.05 \cdot 0\$; thus $$ p = \displaystyle\frac{0.55 \cdot 1 + 0.05 \cdot 0}{0.60}. $$

But it's even simpler to look at this result and see that we can arrive at it by simply disregarding the no-information cases. 60% of the time (12 die faces), we get information about the result (in fact, we get all the information). One of those die faces immediately represents a failure, and the other 11 represent success. We have effectively just shrunk the d20 to a d12, and our chance of success is 11/12.

And, naturally, that generalizes: if every die result represents either immediate success, immediate failure or "start over and roll again", then we can compute the result by simply pretending the latter kind of die face doesn't exist. We just compute \$\displaystyle\frac{s}{s+f}\$ where \$s\$ is the number of die faces representing success and \$f\$ is the number of die faces representing failure.

Because the sum of the geometric series must also give us the correct answer, then, it follows that we can equate the sum to the more easily calculated result, and thus prove the formula.

\$\endgroup\$
0
22
+150
\$\begingroup\$

Rolling the last d20, we can ignore the 2 through 9 results, since they can't happen. Therefore there are 12 outcomes that can happen: 1 and 10-20, each with equal probability, namely 1/12. So the chance of the higher event is 11/12.

Compare to this prior answer.

\$\endgroup\$
1
  • 5
    \$\begingroup\$ I think this is the simplest and most intuitive answer. If you roll 2 through 9, you just roll again, so it's like they don't exist at all, and you're just rolling a d12. Then you just need to determine the probability of rolling anything but a 1 on a d12 (which is quite obviously 11/12). \$\endgroup\$ Commented Feb 5 at 20:07
1
\$\begingroup\$

Conditional probability

We can somewhat formalize the answers of Karl Knechtel and Daniel R. Collins by using conditional probablity:

$$ P \left(A | B \right) = \frac{P \left(A \cap B\right)}{P\left( B \right)} $$

In this case:

  • \$P \left(A | B \right)\$ is the chance of rolling a success on a d20, conditioned on us stopping rolling on that die.
  • \$P \left(A \cap B\right) = s\$ is the chance of rolling a success on a d20.
  • \$P \left(B\right) = s + f\$ is the chance of stopping rolling on a d20.

Thus, we really can just drop all of the rerolled numbers from the denominator.

Limited rerolls

Eddymage's geometric series approach, while involving a more complex series sum, does have another advantage: it lends itself naturally to cases where the depth of the rerolls is limited. If we are allowed up to \$d\$ rerolls, the probability of success is the combined chance of rerolling \$i\$ times then succeeding on the \$i+1\$th roll. The expression for a partial sum of a geometric series then gives the chance of success as

$$ \sum_{i=0}^{d} s \left(1 - s - f\right)^i = s \frac{1 - \left(1 - s - f\right)^{d+1}}{s + f} $$

and similarly for failing on a 1:

$$ f \frac{1 - \left(1 - s - f\right)^{d+1}}{s + f} $$

The chance of failing on a number that would have been rerollable had we not hit the max depth (i.e. 2-9 in the original question) is the probability we exhaust all \$d\$ rerolls, and then roll one of those numbers:

$$ \left(1 - s - f\right)^{d+1} $$

For example, this could represent a situation where a monster is breaking down your door and you have \$d+1\$ tries to trick a magic item into letting you escape in time.

Example implementation

Indeed, this is how I implemented rerolls in my Icepool Python probability package:

if depth is None:
    data = {
        outcome: quantity
        for outcome, quantity in self.items()
        if outcome not in outcome_set
    }
elif depth < 0:
    raise ValueError('reroll depth cannot be negative.')
else:
    total_reroll_quantity = sum(quantity
                                for outcome, quantity in self.items()
                                if outcome in outcome_set)
    total_stop_quantity = self.denominator() - total_reroll_quantity
    rerollable_factor = total_reroll_quantity**depth
    stop_factor = (self.denominator()**(depth + 1) - rerollable_factor
                   * total_reroll_quantity) // total_stop_quantity
    data = {
        outcome: (rerollable_factor *
                  quantity if outcome in outcome_set else stop_factor *
                  quantity)
        for outcome, quantity in self.items()
    }
return icepool.Die(data)

There's a little extra work to be done here since I decided to use unnormalized integer quantities in order to avoid floating-point precision issues.

\$\endgroup\$
0
\$\begingroup\$

You've got the right math, but you're caring about the wrong result.

Since the chance of failure is smaller, you should figure out what the chance of failure is, then get the chance of success from that. You know you're more likely to win, so what you really want to know is how likely you'll lose?

And the chance of failure converges to somewhere near 9% after 4 iterations. The formulas others have provided say that it's really like 9.1%, but after 3 iterations, it's at ~8% which is only off by 1.1%. Do you need more precision than ~8%?

First roll: 5% failure, 40% reroll, 55% success.

Second roll (40% chance * First Roll probabilities): 2% failure, 16% reroll, 22% success.

Third roll: 0.8% failure, 6.4% reroll, 8.8% success.

Fourth roll: 0.32% failure...

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .