Probability of getting a certain number: rolling a die with x number of sides, with advantage In D&D when you have advantage or disadvantage you roll your die twice (ex 3&7), and pick the higher number($7$). When you have disadvantage you pick the lower($3$). I want to know how to calculate the probability of getting a certain number with a $s$ sided die with advantage and disadvantage (getting 1 with 20 sided die with advantage is 1/400(.25%) because it would require both dice to be 1; getting 2 is 1/100(1%) because the only possibilities are: 1,1;1,2;2,1;2,2)
What would the formula look like?
What if instead of the same die rolled twice: there were two different sided die? (Ex 20 sided and 10 sided)
 A: You can translate the problem as a count of sequences. By example you have a sequence $(a_1,a_2,...,a_n)$ where each term represent a dice, then you want to count the number of sequences that hold some conditions.
By example Im searching the sequences where the maximum value $M\in A$ and the minimum value $m\in B$. When a dice hold some condition I symbolize it as $M$, $m$ or $X$ for a different value.
If I have 4 dice the sequences $(M,M,M,m)$ or $(X,M,X,m)$ hold the conditions for a maximum value and a minimum.
Some example: I want to know the number of throws where the maximum value is $M\ge 10$ and the minimum is $m\le 3$, and my throw is composed by 2 dice of 20 side (2D20) a dice of 10 side (1D10) and a dice of 6 side (1D6), and for simplicity the values of the sides for each dice go from 1 to it number of sides, and all side have the same probability to be (i.e. they are fair dice).
I order my sequence putting in the 2 first place the 2D20, after the 1D10 and last the 1D6, i.e. $(D20,D20,D10,D6)$. Now I want to know the number of sequences of the kind $(a_1,a_2,a_3,a_4)$ where $a_i\in\{X,M,m\}$.
Each $a_i$ can hold or not some condition, by example $a_4$ cant hold $M$ condition because it maximum value is $6$ so $a_4\in\{X,m\}$ so the total number of sequences will be anything with at least one $M$ and one $m$.
Each symbolic sequence have associated a number of sequences, by example $XMMm=6*11*1*3$. When the dice are different it is hard to search a closed formula for it, but for equal dice we can simplify it a lot.
Sometimes it easier to count the sequences that dont hold some condition. In the anterior example we can count all the sequences with $\forall a_i \in\{X,M\}$ and the sequences $\forall a_i \in\{X,m\}$, add them and subtract at the total number of possible sequences to get the probability that we want.
Another approach can be encode the information that we want on some kind of algebraic property, using some knowledge of theory of numbers. With some exponential scale we can make sums that encode qualitative information.
I will think in a way to encode all of this in a generating function. Anyway this is not a perfect answer because it doesnt means that exist a closed formula for every case that you want.
A: Let $i,j$ denote the two outcomes of the rolling of the two dice. If $i\not =j$ then there are two realizations: $(i,j)$ and $(j,i)$. For $(i,i)$ there is only one realization.
Having said that consider an $s$ sided die and the advantage case and the number $k$. We have the following possibilities:
$$(1,k),(2,k),...(k,k)$$
out of which $k-1$ have two possible realizations and one, $(k,k)$ has only one possible realization. So the probability of getting $k$ in this case is
$$2\frac{k-1}{s^2}+\frac1{s^2}=\frac{2k-1}{s^2}.$$
With disadvantage we have
$$(k,k),(k,k+1),...,(k,s)$$
out of which $s-k$ have $2$ possible realizations and $1$, $(k,k)$ again, has only one realization. So, the probability of getting $k$ with disadvantage is
$$2\frac{s-k}{s^2}+\frac1{s^2}=\frac{2s-2k+1}{s^2}.$$
A: Rolling with Advantage
The probability of getting $n$ on $d$-sided dice with advantage is the probability either of getting $n$ on both dice, $\left(\frac1d\right)^2=\frac1{d^2}$, or $n$ on one die and from $1$ to $n-1$ on the other, $2\frac{n-1}d\frac1d=\frac{2n-2}{d^2}$. Thus, the probability is
$$
\frac{2n-1}{d^2}
$$
Another way of thinking of this is that the probability of getting at most $n$ on two $d$-sided dice is $\left(\frac nd\right)^2=\frac{n^2}{d^2}$. Thus, the probability of getting exactly $n$ is the probability of getting at most $n$ but not getting at most $n-1$, that is $\frac{n^2}{d^2}-\frac{(n-1)^2}{d^2}$, which is
$$
\frac{2n-1}{d^2}
$$
as above.

Rolling with Disadvantage
Rolling with disadvantage is the same as rolling with advantage, but subtracting the roll of each die from $d+1$. That is, getting $n$ on two $d$-sided dice with disadvantage is the same as getting $d-n+1$ with advantage:
$$
\frac{2(d-n+1)-1}{d^2}=\frac{2d-2n+1}{d^2}
$$
