Probability formula, a value chosen at random is greater than another chosen value. Say I have two number ranges, whole numbers only.
Range 1: [-3,16]
Range 2: [3,22]
I choose randomly one number from Range 1 and one number from Range 2.
Lets call them x and y.
How do I find the probability that the number x will be greater than the number y?
 A: $$P(x > y) = P(x,y \in [3,16])[1/2 *P(no\:\: tie \: | \: x,y \in [3,16])]$$
$$= (14/20)(14/20)(1/2 * 13/14)$$
$$ = 91/400.$$
To check your reasoning on these things, I suggest downloading the free program called R and doing a quick sim like this:

X = -3:16
Y = 3:22
sims = 0
count = 0
while(1) {
  x = sample(X,1)
  y = sample(Y,1)
  if (x > y) count = count + 1
  sims = sims + 1
}
p = count/sims
error = 3.29*sqrt(p*(1-p)/sims)
p
p-error
p+error
91/400
sims

Output:

> p
[1] 0.2276158
> p-error
[1] 0.2271114
> p+error
[1] 0.2281201
> 91/400
[1] 0.2275
> sims
[1] 7480549

Shown is the 99.9% confidence interval.  This runs until you break it, and you can restart it from the main while loop to have it continue until the confidence interval is as tight as you want.
A: One way you could do this is the following:
Let $X$ be the number from the first range, and let $Y$ be the number from the second.
$$\mathbb{P}(X>Y)=\sum_{y\in \{3;22\}}\mathbb{P}(X>Y \mid Y=y)\mathbb{P}(Y=y)$$
The probability that $X>Y$ given that $Y=y$ is easily determined by counting what fraction of the possible values of $X$ are larger than $y$.  This type of computation is easily implemented on a computer.  By hand, it could be pretty tedious.  In general of course you'd replace the sum $y\in \{3;22\}$ with $y\in \text{Range 2}$, i.e. $y$ is over all the possible values of $Y$.
If you write out what those conditional probabilities are you'll notice a pattern in how the values change from one term in the sum to the next.  This may lead you (with a little effort) to an easier-to-compute closed form...
A: *

*The sample space is $20\cdot20$ = 400


*Chances of x > y are only in the interval [3,16]


*In the $14\cdot14$ = 196 sample points, there will be 14 ties,
and by symmetry, for $\frac12$ of the rest , x > y, hence ans = $\frac{91}{400}$
A: Let us denote by R the rectangular region $[-3,16]\times[3,22]$. The required probability is $P(X>Y)=P((X,Y)\in D)$, where $D=\{(x,y)\in R, x>y\}$.
A short computation illustrates that D is the triangle of vertices (3,3), (16,3), (16,16), having the area equal to $13^2/2$.
Now we have  $P(X>Y)=P((X,Y)\in D)=\dfrac{area(D)}{area(R)}=\dfrac{13^2}{2\cdot 19^2}$.

Here is the Python code simulating $(X,Y)$:
import numpy as np
k=0
nr=0
N=5000
for k in range(N):
  x=-3+19*np.random.random()
  y=3+19*np.random.random()
  if x>y:
      nr+=1

    print 'Experimental prob=', float(nr)/N,  'Theoretical prob=', 13.0**2/(2*19**2),\
 '\nBruceZ probability=', float(91)/400

    >>> Experimental prob= 0.231 Theoretical prob= 0.234072022161 
 BruceZ probability= 0.2275

