# probability of A dice with X faces beating B dice with Y faces

I am looking for a formula to determine the probability of a A Die with X faces rolling higher than B die with Y faces.

An example would be: what is the probability of 4d10 rolling greater than 3d12

Edit: I thought the last edit summary would pop up but it didnt, so added here. Corrected the question a bit and added example.

Edit #2: I had come up with a similar conclusion for percentages (x-1/2y) in a case of dx vs dy

But I didnt took into account the difference on whether "x" was larger or smaller than "y".

However what about when there is more than one dice of the same type is it still the same formula? considering the sum is a bit more irregular since some numbers repeat more often than others do I replace "x" and "y" with the total sum of possible outcomes of each die combination? (in xda I assume the total is a^x)

-
Your subject says "A dice", so I thought A is how many dice there are. But then your question says "An A die", so it looks as if "A" is merely the name of that particular die. – Michael Hardy Nov 18 '12 at 23:10
@Michael: the example added latter (4d10 v. 3d12) suggests that the title is the intended version, with many dice rather than just two. – Henry Nov 19 '12 at 0:14

If you get a $k$ on the die with $X$ faces (where obviously $1\le k\le X$), there are $k-1$ numbers that you can beat. The probability that one of these numbers comes up on the die with $Y$ faces is

$$\min\left\{\frac{k-1}Y,1\right\}\;,$$

so the desired probability is

$$\sum_{k=1}^X\frac1X\min\left\{\frac{k-1}Y,1\right\}=\frac1X\sum_{k=1}^{X-1}\min\left\{\frac{k}Y,1\right\}\;.$$

If $X\le Y+1$ this is $$\frac1X\sum_{k=1}^{X-1}\frac{k}Y=\frac1{XY}\sum_{k=1}^{X-1}k=\frac{X(X-1)}{2XY}=\frac{X-1}{2Y}\;.$$ If $X>Y+1$ it’s

$$\frac1X\sum_{k=1}^{Y-1}\frac{k}Y+\sum_{k=Y+1}^X\frac1X=\frac{Y-1}{2X}+\frac{X-Y}X=1-\frac{Y+1}{2X}\;.$$

-

For small numbers of dice, the easiest approach is to calculate the exact answer using a spreadsheet. The columns are numbers of dice and rows are values of the sum. In each cell is the number of ways to make that sum with that many dice. To find the probability of each sum in the case of 4d10 you start with column A for the sums, starting at -10 and going up high enough. Column B is for no dice, so you put a 1 in the cell for 0. Column C is for 1 die and in each cell you sum the ten rows above from the column to the right. This will put a 1 in each row from sum $1$ through sum $10$. The reason we started with a sum of $-10$ is to avoid running off the top of the sheet. The probability of each sum is then the entry in the cell divided by $10^n$. If you have access to a programming language, it would not be hard to code this. It would probably be less work if you have several sizes of dice to consider.

If you do this for 4d10 and 3d12, for each roll of 4d10 you can calculate the number of 3d12 rolls it will beat and add them up.

For large numbers of dice, you can use the normal approximation to the sum of uniform distributions. The mean roll of d10 is 5.5 and the variance is $\frac {99}{12}$

-

We obtain separate formulas for the case $X\le Y$ and $X\ge Y$.

It is useful to calculate first the probability that if two dice have the same number $N$ of faces, then the first die beats the second. With probability $\dfrac{1}{N}$ the results are the same, so with probability $1-\dfrac{1}{N}=\dfrac{N-1}{N}$ they are different. If they are different, by symmetry the probability the first is higher is $\dfrac{1}{2}$. So the probability the first die gives a number higher than the second is $$\dfrac{N-1}{2N}.$$ Call this result the Basic Fact.

Case 1: $X \le Y$. With probability $\dfrac{X}{Y}$, the result on the second die is $\le X$. Given that the result on the second die is $\le X$, by the Basic Fact, the probability the result on A is bigger than the result on B is $\dfrac{X-1}{2X}$.

It follows that the probability the A die wins is, in this case, $\dfrac{X}{Y}\cdot \dfrac{X-1}{2X}$. This simplifies to $$\dfrac{X-1}{2Y}.$$

Case 2: $X \ge Y$. Here A can win in $2$ ways. If A rolls a number $\gt Y$, there is an automatic win. The probability of this is $\dfrac{X-Y}{X}$. If A rolls a number $\le Y$, which has probability $\dfrac{Y}{X}$, then by the Basic Fact the probability A wins is $\dfrac{Y-1}{2Y}$. So our probability is $$\frac{X-Y}{X}+\frac{Y}{X}\cdot \frac{Y-1}{2Y}.$$ This can be simplified to $$1-\frac{Y+1}{2X}.$$

-