[RPG] How to figure the number of trials until success

dnd-5eskillsstatistics

I have a player who I want to let make many attempts at the same skill check. (I'm aware that's not always the best way to do it, but it makes sense in some cases.) But rather than rolling many times until success, I'd like a single roll to tell me the number of attempts–and therefore the in-game time–it could take my player's character to succeed.

I'm aware that the expected time to success, given each individual trial's chance of success \$p\$, is given by \$\overline{T}=\frac{1}{p}\$. (See also.) But I want something that could give different outcomes, simulating the results of iterated skill checks.

How can I simulate iterated skill checks with one die roll?


This question motivated by the comment-colloquy here, reproduced below for posterity:

A: I'm talking probability of 1 trial to success (= P obviously), probability at most 2 trials to success, at most 3, etc… And in turn, a way to turn a single roll (representing how good your result is in the relevant probability space) into "how many actual trials to success".

B: Ah, so are you talking something like taking p=0.5 you'd generate a percentile table: 01-50=>1, 51-75=>2, 76-87=>3, &c.? So that one percentile roll would give a properly distributed number of trials to success in this instance?

A: yeah

Best Answer

You want a table that models "stacked" probabilities.

For example, if the chance of any individual attempt's success is 40%, your table might look like this:

\begin{array}{cc} n\text{ to success} & \text{d}100\text{ roll}\\ \hline 1 & 01-40\\ 2 & 41-64\\ 3 & 65-78\\ 4 & 79-87\\ 5 & 88-92\\ 6 & 93-95\\ 7 & 96-97\\ 8 & 98\\ 9 & 99\\ 10 & 100\\ \end{array}

But how do you generate this table?


Given the probability \$p\$ of succeeding on any given attempt, then the probability of succeeding on the \$n^\text{th}\$ attempt is given by $$P(n)=(1-p)^{n-1}\cdot p$$

This is because in order to succeed on the \$n^\text{th}\$ attempt we must first fail, with a probability \$(1-p)\$, \$n-1\$ times, then succeed (with probability \$p\$).

Thus in the example above we see that \begin{align*} P(1)&=p=0.4\\ P(2)&=(1-p)\cdot p =0.24\\ P(3)&=(1-p)^2\cdot p \approx0.14\\ P(4)&=(1-p)^3\cdot p \approx 0.09\\ \vdots\quad& \hspace{2cm}\vdots \end{align*}

But in order to stack the probabilities we recognize that the "break points"--the highest number in each of the percentile ranges--are given by the sum of all probabilities up to the \$n^\text{th}\$. Luckily, this is just a geometric series: $$\sum_{i=0}^{n-1}{(1-p)^i} = \frac{1-(1-p)^n}{p}$$

With this in hand it's easy to generate a table of "break points" for any given \$p\$:

\begin{array}{c|ccccccc} & \text{d}100\text{ roll}\\ n\text{ to success} & p=0.1 & p=0.2 & p=0.3 & p=0.4 & p=0.5 &p=0.6 &p=0.7\\ \hline 1 & 01-10 & 01-20 & 01-30 & 01-40 & 01-50 & 01-60 & 01-70\\ 2 & 11-19 & 21-36 & 31-51 & 41-64 & 51-75 & 61-84 & 71-91\\ 3 & 20-27 & 37-49 & 52-66 & 65-78 & 76-88 & 85-94 & 92-97\\ 4 & 28-34 & 50-59 & 67-76 & 79-87 & 89-94 & 95-97 & 98-99\\ \hline 5 & 35-41 & 60-67 & 77-83 & 88-92 & 95-97 & 98-99 & 100\\ 6 & 42-47 & 68-74 & 84-88 & 93-95 & 98 & 100\\ 7 & 48-52 & 75-79 & 89-92 & 97-97 & 99\\ 8 & 53-57 & 80-83 & 93-94 & 98 & 100\\\hline 9 & 58-61 & 84-87 & 95-96 & 99 & \\ 10 & 62-65 & 88-89 & 97 & 99 & \\ 11 & 66-69 & 90-91 & 98 & 100 & \\ 12 & 70-72 & 92-93 & 99 & & \\\hline 13 & 73-75 & 94-95 & 99 & & \\ 14 & 76-77 & 96 & 99 & & \\ 15 & 78-79 & 96 & 100 & & \\ 16 & 80-81 & 97 & & & \\ \vdots & \vdots & \vdots\\ \end{array}

Notes:

1. In a few places the same single number appears twice. (p=0.2, n=14,15, for instance.) In these cases multiple break-points round to the same percent-value. You could randomly choose from among n values if this is rolled, simply take the lower, or devise some other scheme.

2. Obviously, there is a non-zero probability that success would take longer than I've indicated, ending my tables at the first appearance of a rounded-to-100 percent-value. However, by construction there is less than a 1/2% chance that any n greater than the last presented could occur. I felt fine leaving the long tail off the table.