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)
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} $$