Opposed rolls all work the same way. Each side rolls a d20 and adds a modifier to it. Whoever has the highest modifier wins the tie. Here's how I think about it (may not be the best way of solving it, but it works):
Treat the monster's roll as a probability and yours as a fixed variable. Examine it case by case. Each of your rolls has a probability of 1/20, calculate the probability that the monster could beat your roll with the modifiers in place. Multiply that probability by 1/20 and sum over all twenty events. The total result cannot be greater than 100%. To put it in generalized terms:
N
-1ΣPr(X+n<Z+Y), where X is your modifier to the opposed roll, the sum index is n (ranging from 1 to N), Z is the monster's modifier, and Y an RV representing his roll (uniform discrete from 1 to N).
Basically the only chore is to figure out how many possible rolls there are such that the monster succeeds, ie where X+n < Z + Y is satisfied. We restrict outselves to the case where X-Z <N. If Z-X >= N+1, then we always lose. Take a concrete example, Z = +15, X = +10, and you roll a 6. The monster needs to roll a 2 or better, leaving 19 possible rolls in which he could succeed. For any roll of 5 or lower on your part, the monster always succeeds, contributing a total of 25% to his total probability of success. In variables, that's (N+[Z-(X+n)]). Plug in N = 20, Z = 15, X = 10, and n = 6, and you'll see it gives 19, that is 19 possible rolls to succeed. Going into this we knew that we needed to roll better than (Z-X), since Z > X. Now we have a general formula for Z > X.
N
-2Σ(N+[Z-(X+n)]) + N
-1(Z-X), where n ranges from (Z-X+1) to N.
Now lets evaluate the sum... this will require a few tricks. If you don't follow... I'm sorry. I'll write out each step.
N
-2Σ(N+[Z-(X+n)]) = N
-2Σ(N+Z-X)-N
-2Σ(n), both sums over the original range.
N
-2(N+Z-X)(N-(Z-X))-N
-2N(N+1)/2 + N
-2(Z-X)(Z-X+1)/2
Bringing the total to:
N
-2(N+Z-X)(N-(Z-X))-N
-2N(N+1)/2 + N
-2(Z-X)(Z-X+1)/2+N
-1(Z-X)
Just to check, lets try the original case, plugging in N = 20, X = 10, Z = 15.
(1/400)(25)(15)-210/400+15/400+100/400= 280/400 = 70%. Meaning you would only have a 30% chance of beating a monster in this opposed check.
Now lets look at the case where Z<X. We will restrict ourselves to the case X-Z <N, because if X-Z >= N, we'd always win. Again, let’s use a concrete example. Z = 10, X = 15, and you roll a 6. The monster has to roll a 12 to beat you, giving him 9 possible rolls to succeed. So N-([X+n]-Z) gives the number of possible rolls. The monster always fails for rolls less than 7, so the best he can get is a 70% success rate (he automatically fails 6/20 times). In variables, that's (X+1)-Z automatic failures. We, as the player, needn't roll any higher than N-(X-Z) to ensure success on our part. I translate this to mean that the monster automatically fails for n > N-(X-Z). We're now in position to calculate the general formula for X > Z.
N
-2Σ(N-[(X+n)-Z]), where n ranges from 1 to N-(X-Z)-1.
Evaluation time... again standard manipulations to evaluate the sum
N
-2Σ(N-[(X+n)-Z]) = N
-2Σ(N-X+Z]) - N
-2Σ(n), both sums over the original range.
N
-2(N-(X-Z)-1)(N-X+Z) - N
-2(N-(X-Z))(N-(X-Z)-1)/2
Bringing the total to:
(1/2)N
-2(N-(X-Z)-1)(N-X+Z)
Again, lets check with the variables from the original scenario to make sure I didn't screw up badly:
1-(1/2)(1/400)(14)(15) = 1-105/400 = .7375.
Note the above derivation assumes that the offender wins the tie, this is actually wrong in retrospect, so rather than redoing all the sums, I'm just going to calculate the tie probability. Then we'll subtract it from the "offender".
Same deal as before, we need to find all the possible rolls such that the condition X + n = Z + Y. In other words X-Z = Y-n. Obviously if Z-X > N, then the two cannot ever be equal. Likewise, if X-Z > N, then the two cannot ever be equal. These form the bounds for our problem. The interesting thing is that for all the possible values of X + n (ranging from X + 1 to X + N), there is only one combination Z + Y that will satisfy the tie condition. The only difficulty then becomes discovering the range for n. Basically we're going to have two scenarios: your mod is bigger or the monster's mod is bigger. If your mod is bigger then the range of n in the sum is from 1 to N - (X-Z). If your mod is smaller, the sum ranges from Z-X+1 to N. So basically we come up with these to formulas:
If your mod is bigger: Tie probability = N
-2*(N-X+Z)
If your mod is smaller: Tie probability = N
-2*(N-Z+X)
Wanna check? Take my mod to be 15 and the monster's to be 10. Check that link (below) and you'll see that the tie probability is 3.8%. My formula gives: (20-15+10)/400 = 15/400 = 3.75 %. The other one is the exact same thing, just with the modifiers reversed in role. So now our final formulas come to:
If your mod is bigger:
Probability of Success = 1 - (1/2)N
-2(N-(X-Z)-1)(N-X+Z), where X = your modifier, Z = monster modifier
If your mod is smaller:
1 - (1/2)N
-2[((N-(Z-X))(N-(Z-X)+1) - 2(N-Z+X)], where X = your modifier, Z = monster modifier
In a moment of insecurity, I decided to check these numbers against what other people have said. I googled a bit and came to this site:
>>LINK<<His numbers agree with mine (rounded to one decimal place). Just add the tie probability to the win probability to see. To check the case Z > X, add the tie probability to the lose and you get the 70/30 split I calculated.