# dnd 5e – How do I calculate d20 success probability using the Halfling ‘lucky’ trait with (dis)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: $$L = P + frac{1}{20}P,$$ $$L_{adv} = P_{adv} + left(frac{2}{20}(1 – P) – frac{1}{400}right)P,$$ $$L_{dis} = P_{dis} + frac{2}{20}P^2,$$ where:

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

The \$P\$s are quite easy to derive, and \$L\$ is just passing outright OR (rolling a 1 AND THEN passing the reroll): $$L = P + left(frac{1}{20}*Pright).$$ But I’m struggling with deriving \$L_{adv}\$ and \$L_{dis}\$. Please can someone show a derivation?