# How can I figure the number of trials until success?

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

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.

• Interesting table. I don't think there is any other way of doing what you want whilst staying true to the exact mechanics you want to simulate. If you consider the relative ease of rolling a die repeatedly, vs accessing the pre-computed table then using it, then you can determine whether this approach is worth the effort. For low p values it might be. My cut-off to "just roll many times" is probably around p>=0.3 (given that 9 times out of 10, we'd roll less than 8 times). – Neil Slater Jan 1 '17 at 11:07
• It's the sort of thing I could see being useful to a GM who plays with a laptop to hand. It's super-easy to code this into a spreadsheet and just input the p-value up top, watching the whole column update. Or, if you're really into creating situations where unchanging repetition happens and time really matters, maybe you print a table like this and tape it to your screen. – nitsua60 Jan 1 '17 at 13:49
• @nitsua60 As a GM who religiously uses his laptop at the gaming table for character sheets, bookmarked PDF documents, checking online system reference documents for obscure rules/details, and using random generators, I could definitely see myself incorporating this into a spreadsheet just as you describe. – Dyndrilliac Jan 2 '17 at 16:40

## Roll 3d($$\3\overline{T}\$$), take the lowest.

As you say, the expected time to success, given the probability of any individual trial succeeding is $$\p\$$, is given by $$\\overline{T}=\frac{1}{p}\$$.

If you figure that expected time-to-success, triple it, roll three of that die-size, and take the lowest, you'll get a very good approximation of the right distribution.

For example, suppose you have a +5 modifier and encounter a DC20 challenge:

1. You then have a 30% chance of success ($$\p=0.3\$$);
2. $$\\overline{T}=\frac{1}{p}=3 \frac{1}{3}\$$;
3. $$\3\overline{T}=10\$$, so d10 are our needed dice;
4. roll 3d10, take the lowest.

Below are pictured comparisons for various $$\p\$$ values. The exact values are the probability of each n being the successful trial, calculated as in this answer. The approximate values are those obtained through anydice simulation of the roll-three-take-lowest method. [Click for larger image]

Obviously this method assumes you're pretty happy doing some mental math: figuring the expected time to success, then probably simulating some off-sided dice with standard die rolls.