# How does one Calculate Dual Variable Probability?

## How do we determine the probability of given grapple to succeed?

In DnD 3.5 the grapple mechanic relies on double variable randomness in order to determine success or failure. This double randomness increases both the possibility of success and failure at the extreme ends of the situation - but also creates the chance of success where otherwise there wouldn't be one.

How does one calculate or generate a number or probability summmary for a single event in a meaningful way that can be easily understood?

In this case is it a D20+Modifiers(A) VS D20+Modifiers(B) - with tie breakers going to a predetermined value (Whomever has the highest grapple check).

So some questions:

1. How do I calculate or determine this?
2. Is there an easy summary to calculate the overall probility if we simply know the difference in modifiers? (For example, +2 in favor of Mod A, or +3 in Favor of Mod B)

This is a supporting question for:

Is it a viable tactic to use a flurry of blows monk to mass grapple a single target?

• This may be better suited for math.stackexchange.com , although there are some of us math geeks here. I'll give it a brief stab here
– Alan
Feb 7, 2023 at 5:49
• The only mention I see of ties during a grapple is during Step 3: Hold: "In case of a tie, the combatant with the higher grapple check modifier wins. If this is a tie, roll again to break the tie" (PH 156). Am I not seeing it, or should I be looking elsewhere? Feb 7, 2023 at 5:53
• A creature's base attack bonus may be much different from its grapple check modifier. (It's why a monster's stat block has the entry Base Attack/Grapple, after all.) Feb 7, 2023 at 5:59
• The math is the exact same no matter how you generate the d20+ modifiers, though admittedly the extra tiebreaker complicates it a bit. It's so small an edge case though it can likely be ignored and you will still be pretty safe. I worked out the answer as I typed it in, so you can see how the derivation of the answer goes.
– Alan
Feb 7, 2023 at 6:23
• This is a great place to plug Prof. Torben Mogensen's classic paper on dice mechanisms in role-playing games. It should be fairly easy to understand even if you are not a Maths geek... Feb 10, 2023 at 1:14

It helps to remember that, even when dealing with random variables, we're still allowed to move terms from one side of the (in)equality sign to the other (and change their sign). So this: $${\rm d}20 + M_A > {\rm d}20 + M_B \tag1$$ is equivalent to this: $${\rm d}20 - {\rm d}20 > M_B - M_A \tag2$$

(In high school math education, this "moving terms from one side to the other and changing their sign" is often presented as "adding (or subtracting) the same term from each side", followed by canceling out terms that sum to zero. Which is fine too, except that we need to remember that the two "$$\{\rm d}20\$$" terms above are not the same — they represent separate rolls and don't cancel out when one is subtracted from the other! It might be clearer to mark them explicitly as, say, "$$\{\rm d}20_A\$$" and "$$\{\rm d}20_B\$$" to make it clear that they are actually different random variables, but that's not how dice rolls are usually notated in RPGs.)

Now, what's $$\{\rm d}20 - {\rm d}20\$$ (keeping in mind that, as noted above, these two "$$\{\rm d}20\$$" terms denote separate die rolls)? A moment's thought will show that it's the sum of $$\{\rm d}20\$$ and $$\-{\rm d}20\$$, where the latter is a die that rolls a uniformly distributed number between $$\-20\$$ and $$\-1\$$. In other words, a $$\-\mathrm d20\$$ is the same as $$\{\rm d}20 - 21\$$, and so: $${\rm d}20 - {\rm d}20 \overset d= 2{\rm d}20 - 21$$

(Here, "$$\\overset d=\$$" means "equal in distribution". The two sides here are obviously not the same random variable — if you first roll $$\{\rm d}20 - {\rm d}20\$$ and then $$\2{\rm d}20 - 21\$$, you will not usually get the same number from both rolls! — but they do have the same distribution, i.e. the same probability of rolling any given result.)

Substituting this into inequality $$\(2)\$$ above, we can thus see that $$\(1)\$$ and $$\(2)\$$ are equivalent (in distribution!) to: $$2{\rm d}20 - 21 > M_B - M_A \tag3$$ or, equivalently: $$2{\rm d}20 > M_B - M_A + 21 \tag4$$

So, what did we learn from this (besides some hopefully useful algebraic rules for dice rolls)?

One obvious conclusion is that the individual modifiers for players A and B don't matter — all that matters is their difference. Giving +1 to player A is equivalent to giving -1 to player B, and vice versa. And giving +1 to both players doesn't change the odds at all.

Also, the separate d20 rolls don't really matter, either — you can implement the same mechanic with a single 2d20 roll.

Also, for reference and intuitive understanding, here's what a roll of 2d20 − 21 (or, equivalently, d20 − d20) looks like:

The distribution is mirror symmetric around zero and shaped like an upside-down letter V, increasing linearly from 0.25% at -19 up to 5% at 0, and then decreasing linearly back to 0.25% at 19. (Don't ask me why AnyDice chooses to place the tick marks on odd numbers in the plot.)

It may also be useful to look at the probability of rolling at least a given target number (i.e. difference of modifiers) on such a roll:

As we can see, when both players have the same modifier, the probability of either player winning contested dice roll is the same (47.5%), with a 5% chance of the dice rolling the same number and the tie breaker rule having to be applied.

As the difference in the modifiers increases, the chance of the player with the higher modifier winning of course increases. Going from +0 to +1 increases the win rate (ignoring ties) for the player with the higher modifier by 5%, from 47.5% to 52.5%. Increasing difference further increases the win rate further, but less (in fact, exactly 0.25% less) for each further point of difference.

The chance of rolling a tie also decreases by 0.25% for each additional point of difference between the modifiers. This is not a coincidence: changing the difference between the modifiers changes the threshold where the 2d20 roll goes from a win to a tie, and then from a tie to a loss. So changing the difference by +1 turns what would've been ties into wins, and some of what would've been losses into ties.

Here's a convenient table:

Difference in modifiers (MAMB) A wins Tie B wins
0 47.5% 5% 47.5%
+1 52.5% 4.75% 42.75%
+2 57.25% 4.5% 38.25%
+3 61.75% 4.25% 34%
+4 66% 4% 30%
+5 70% 3.75% 26.25%
+6 73.75% 3.5% 22.75%
+7 77.25% 3.25% 19.5%
+8 80.5% 3% 16.5%
+9 83.5% 2.75% 13.75%
+10 86.25% 2.5% 11.25%
+11 88.75% 2.25% 9%
+12 91% 2% 7%
+13 93% 1.75% 5.25%
+14 94.75% 1.5% 3.75%
+15 96.25% 1.25% 2.5%
+16 97.5% 1% 1.5%
+17 98.5% 0.75% 0.75%
+18 99.25% 0.5% 0.25%
+19 99.75% 0.25% 0%
+20 100% 0% 0%

For brevity this just half the table, showing only the cases where MA ≥ MB. If player B has the higher modifier, just swap the player labels when consulting the table.

• Line Graphs and a fancy chart! @Alan - you have competition! TY Ilmari! Feb 7, 2023 at 12:39
• grin I like the fact that it showed how to do the math yourself using the anydice. I just did it in googlesheets.
– Alan
Feb 7, 2023 at 18:15

You're looking at a probability space of 400 events (20 times 20) Let's look at a concrete example, say A has a +2 advantage and wins the tiebreaker We can break it down into the 20 rolls A gets, and then count how many of the rolls for B count as a win for A:

If A rolls an 18 through 20 results for B don't matter, A wins, since the best B can do is tie. So there's 60 wins If A rolls a 17, they lose only on a B 20: 19 wins. If A rolls a 16, they lose on a B 20 or 19, 18 wins.

Note the pattern, if A rolls a 1, they lose on a B 4 or higher, 3 wins This is fully exhaustive and each case is disjoint, so we can simply add the number of wins and divide by the number of possibilities The formula for the 3...+19 part is here formula, we get there are 19-3+1=17 numbers (Makes sense, this was A results 1 through 17), so $$\sum_{i=1}^{17}(i+2)=\frac {17(3+19)} 2=187$$ Add these to the 60 wins from before and we get 60+187=247 wins, so a win probability of $$\frac {247} {400}=61.75\%$$

Now, what if B won ties?-This takes away 1 win from A at each step (so only 2 wins if A rolls a 1, through 19 wins of A rolls an 18, with the two 20s at the end, giving us $$40+\sum_{i=1}^{18}(i+1)=40+\frac {18(2+19)} 2=229$$ for a total probability of $$\frac {229} {400}=57.25\%$$

We can clean up both formulae by letting them range up to include the first 20 wins rather then separating them all out, in this case, A +2 with A win looks like the # of wins is

$$2\cdot 20+\sum_{i=1}^{18} i+2=2\cdot 20 + \frac {18(3+20)} 2$$ and with A lose ties it shifts one further down, so $$1\cdot 20+\sum_{i=1}^{19} i+1=1\cdot 20 + \frac {19(2+20)} 2$$ Convert these to probabilities by dividing by 400 then looking as a percentage.

Now we're ready to generalize. Note with A having a margin of +k, $k>0$, if they win ties we are in the first boat and they get that many 20s + all the wins from 1 to 20-k, and on each of those numbers, they get the die roll + k wins. In other words, A has an advantage of k>0 and wins ties:

$$k\cdot 20+\sum_{i=1}^{20-k} i+k=k\cdot 20 + \frac {(20-k)(k+21)} 2$$ wins, divide by 400 for percent If A has advantage of $k>0$ and loses ties, we are in the second formula, where they get k-1 20 wins and then we add the cases from 1 to 21-k, getting each die roll + 1 less than k, i.e. $$(k-1)\cdot 20+\sum_{i=1}^{21-k} i+k-1=(k-1)\cdot 20 + \frac {(21-k)(k+20)} 2$$

again divide by 400 for your probability. If B is greater than A, just do 100%-the above results for A's victory chance. Finally, we have the +0 case. This is simple because we can use symmetry. There are 400 cases, 20 ties. The remaining 380 have to be 190 in A's favor and 190 in B's favor. So if A wins ties at a +0, you get $$\frac {210} {400}=52.5\%$$ and if A loses ties at +0, you get $$\frac {190} {400}=47.5\%$$

After considering the data, it turns out that if B wins the ties, its the exact same formula as if A wins the ties but has 1 less edge, so this one table gives us the what we need. Just consult the amount A has over B on the roll, and subtract 1 if B wins ties. Note this does ignore the tiny edge case of the tiebreaker is a tie and they need to reroll, but that adds more complication than it is worth for the tiny bit of accurac.

A's edge Win %
-1 47.50%
0 52.50%
1 57.25%
2 61.75%
3 66.00%
4 70.00%
5 73.75%
6 77.25%
7 80.50%
8 83.50%
9 86.25%
10 88.75%
11 91.00%
12 93.00%
13 94.75%
14 96.25%
15 97.50%
16 98.50%
17 99.25%
18 99.75%
19 100.00%
• my brain just broke.... faceplants Is their an easy summary - like for each +1 in favor of a side the favored person gets X percent? But I think I understand the gist of it. Would it be easier to just assume that Side A allways wins ties and assume that side A has the higher base grapple value? Feb 7, 2023 at 6:27
• It's a nonlinear relationship, so no. But what you can do is go into excel and program in those formulae, or just plug in numbers for k into them, then divide the result by 400 to get your percent. By nonlinear, I mean if you multiply it out there's a k squared term, so the growth of the difference isn't on a proportional basis
– Alan
Feb 7, 2023 at 6:30
• @PlayPatrice: As long as the grapple values are reasonably close to each other, then each +1 is close to a +4.5% likelihood of a win Feb 7, 2023 at 17:05