Random number from Range1 is greater than Random number from Range2

31 Views Asked by At

This is essentially a dice roll comparison question, but the range of each dice is not 1 to n, but rather x to n+x-1.

I found this equation to determine the odds that a single roll of a 1d(x) is higher than a single roll of a 1d(y) (assuming x > y) as follows...

1 - (y + 1)/2x

I did not proof this myself, so it may be a bad equation.

My question is, how can I determine the odds that a random number from X1 to X2 is greater than a random number from Y1 to Y2? I think this is a dice question, I am just not certain how to factor in the offset.

Thanks

1

There are 1 best solutions below

0
On

We will assume that you split ties evenly. The basic idea is that if both people roll within the overlap of the two ranges, each has a $\frac 12$ chance to win. If at least one does not roll within the overlap range, we know who will win independent of the other roll. Let us assume $Y2 \gt X2, Y1 \gt X1$. Then $Y$ is guaranteed a win when he rolls more than $X2$ or when $X$ rolls less than $Y1$. The chance $Y$ rolls greater than $X2$ is $\frac {Y2-X2}{Y2-Y1+1}$ because there are $Y2-Y1+1$ possible rolls, of which $X2-Y1+1$ are in the overlap zone. Similarly, the chance $X$ rolls less than $Y1$ is $\frac {Y1-X1}{X2-X1+1}$. We can't just add these to get the chance we have a guaranteed winner because we double count the events where $Y$ rolls high and $X$ rolls low. The chance at least one is outside the overlap zone is then $$\frac {Y2-X2}{Y2-Y1+1}+\frac {Y1-X1}{X2-X1+1}-\frac {Y2-X2}{Y2-Y1+1}\cdot\frac {Y1-X1}{X2-X1+1}$$ The chance $Y$ wins is this plus half the chance they both roll inside the overlap zone, so $$\frac {Y2-X2}{Y2-Y1+1}+\frac {Y1-X1}{X2-X1+1}-\frac {Y2-X2}{Y2-Y1+1}\cdot\frac {Y1-X1}{X2-X1+1}+\frac 12\cdot \frac {X2-Y1+1}{Y2-Y1+1}\cdot \frac {X2-Y1+1}{X2-X1+1}$$