# A derivation of the Advantage/Disadvantage probability distributions

In Dungeons and Dragons 5th edition, the Advantage and Disadvantage mechanic provides a straightforward way to tip the scales of fate in favor (or against) the characters depending on the circumstances they face. The mechanic works like this — when rolling a d20 (20-sided dice) to determine the outcome of an action, you instead roll two d20s and keep either the higher result (with advantage) or the lower (with disadvantage). As a result, the odds of particular outcomes change. In this post, we derive the probability distributions that describe those outcomes to better understand how rolling with advantage or disadvantage works.

## Two dice rolls and the comparisons between them

Every dice roll serves as a means to sample from an underlying probability
distribution. As discussed in a
previous post, this underlying distribution is one that picks a
random whole number between 1 and $n$, the number of sides on the dice, which
we can call the *dice roll distribution*.

Rolling two dice does nothing more than generate a sample of size two instead of one from the dice roll distribution. As with most dice rolls, we assume that the outcome on one dice has no effect on the other, or independence.

We write the following to represent our random sample:

Meaning that $X_1$ and $X_2$ each represent the random outcome of an $n$-sided dice roll. Although the advantage/disadvantage mechanic typically applies to $n=20$, it’s straightforward to explore the result for a general value $n$ and substitute in 20 later.

Using our above notation, we mathematically express advantage and disadvantage as the maximum and minimum of the random variables above:

There’s nothing particularly profound here. We’ve just defined explicitly what advantage and disadvantage are.

## A little bit of algebra to get us going

Ultimately, we are interested in the probability that a roll with advantage or disadvantage gives a specific value, e.g. $P(Y_{adv} = y)$. First, let’s focus on advantage. We can start by writing the following:

The probability that the maximum of two random variables is equal to $y$ can be
rewritten as the probability that *one* of the two variables is equal to $y$
and the other is less than $y$. Since either $X_1$ or $X_2$ can be the
maximum, we just add together the same situation but swapped. There is one
edge case this doesn’t capture — if $X_1 = X_2 = y$ — we can add that on to
get the full, correct expression:

As $X_1$ and $X_2$ are independent, the joint probabilities become products, and since $X_1$ and $X_2$ come from the same distribution, we can drop the subscript and just call them $X$ to refer to underlying dice roll distribution.

The first two terms on the right side are identical, we combine them to get:

One minor simplification, as $y$ is discrete, we can write $P(X < y) = P(X \leq y-1)$. This gives (and also using the $Y_{adv}$ notation again)

This gives us the probability mass function of rolling with advantage in terms of the PMF and CDF of the dice roll distribution, $X$. Before we substitute in those functions, let’s quickly go through a similar process for the disadvantage distribution:

Which gives, in similar form to above:

## The probability mass functions

To take our expressions to their simplified forms, we substitute in the functional forms of these probability statements that we found previously. First, we do so for advantage:

Which simplifies to:

For disadvantage:

Which simplifies to:

The above forms show the clear symmetries between the two processes. A great way to really understand what these probability distributions look like is to plot them, like below:

A few things are immediately obvious — advantage shifts the odds in favor of high numbers, disadvantage does the same for low numbers, and they are mirror images of each other. The symmetry is not terribly surprising given the underlying process is symmetric, but it’s nice to see clearly.

Another point worth making is the single most likely outcome for rolling with advantage is the max value of the dice. For disadvantage it’s rolling a 1. While still unlikely in general, it’s notable that you would expect to see the extreme outcomes more often than any other single value.

## The cumulative distribution functions

We can take our work one step further and find the cumulative distribution functions of advantage and disadvantage. Our approach will be to directly calculate:

We’ll start with advantage.

Using the fact that $\sum_{k=1}^y k = y(y+1)/2$, the above expression simplifies to:

We will carry out a nearly identical process for disadvantage:

Similar to before we can evaluate these sums and get our final expression:

Taking a look at these CDFs graphically shows the differing behavior clearly:

They again appear similar but mirrored — advantage grows slowly at first but picks up as it gets to the higher numbers, disadvantage grows quickly and tapers off as you reach the high numbers.

The median provides a good rule of them for these distributions. When rolling with advantage, you are more likely to roll a 15 or higher than below that. With disadvantage, you are more likely to roll a 6 or below than above that. The fact that the bulk of the distributions are pushed closer to the extremes shows just how much of an effect this mechanic has on the potential outcomes.

Advantage and disadvantage is rather simple to implement but does an excellent job at biasing the outcome of dice rolls in whichever way best suits the situation at hand. Since it’s rise in popularity in DnD 5e, it has proliferated to other tabletop games, and some of the results in this post can go a long way towards getting a strong understanding of how advantage and disadvantage really work.