# How do I calculate d20 success probability using the Halfling 'lucky' trait with advantage?

Here is a comprehensive DPR calculator, and here is the mathematics behind it. I'm trying to follow along with the equations.

At the bottom of the second page are formulas for success probability $$\L\$$ of a Halfling (who has luck) in normal circumstances and with advantage and disadvantage. With advantage it is $$L_{adv} = P_{adv} + \left(\frac{2}{20}(1-P) - \frac{1}{400}\right)P,$$ where:

• $$\P\$$ is the probability of succeeding on any single roll and
• $$\P_{adv} = 1 - (1-P)^2\$$ is the probability of succeeding with advantage (ie not failing both rolls).

In my attempt for deriving this (below), I have a sign error. Please can someone explain where I've gone wrong/show a correct derivation?

To succeed you require:

• succeeding outright while advantaged, OR
• rolling a $$\1\$$ with die $$\a\$$ AND failing with die $$\b\$$, AND THEN succeeding the reroll, OR
• rolling a $$\1\$$ with die $$\b\$$ AND failing with die $$\a\$$, AND THEN succeeding the reroll, OR
• rolling two $$\1\$$s AND THEN succeeding a reroll: $$L_{adv} = P_{adv} + \frac{1}{20}*(1-P)*P + \frac{1}{20}*(1-P)*P + \frac{1}{400}*P\\= P_{adv} + \left(\frac{2}{20}(1-P) + \frac{1}{400}\right)P$$
• @Anagkai Please consider putting that into a full answer below Jun 1, 2020 at 12:25

The case where you roll two 1s is actually included in both of the previous two cases (rolling 1 on a, failing on b; rolling 1 on b, failing on a).

Consequently, it has been counted twice and needs to be subtracted from the total instead of added separately.

More generally, this is an example of the Inclusion-Exclusion Principle.

• I see. Becuase there is always the underlying assumption that a 1 always fails (either it's combat, or the trivial case when 1 succeeds is neglected)? Jun 1, 2020 at 10:54
• @jonnybolton16 Yeah, it's more about the trivial case being ignored. Unless there's some special case I've missed, if a 1 succeeds then anything succeeds, so P = 1. The given definition of failing doesn't exclude 1, because it's just given as Prob(failure) = 1 - Prob(success) = 1 - P. Jun 1, 2020 at 10:59
• You cannot reroll both rolls. PHB p.173 "When you have advantage or disadvantage and something in the game, such as the halfling's Lucky trait, lets you reroll the d20, you can reroll only one of the dice." Jun 1, 2020 at 11:51
• @jonnybolton16 Thanks, clearly I missed that! Jun 1, 2020 at 12:02
• @jonnybolton16: Just for completeness - that phrasing has been errataed to also cover things that "replace" rolls. See the basic rules: "When you have advantage or disadvantage and something in the game, such as the halfling's Lucky trait, lets you reroll or replace the d20, you can reroll or replace only one of the dice. You choose which one. For example, if a halfling has advantage or disadvantage on an ability check and rolls a 1 and a 13, the halfling could use the Lucky trait to reroll the 1."
– V2Blast
Jun 1, 2020 at 20:22