[Math] Probability formula, a value chosen at random is greater than another chosen value.

discrete mathematicsprobabilityrandom variables

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?

Best Answer

$$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.