Probability of a random # being > another random # from different sized sets

27 Views Asked by At

I've been working on coding recently, and when I needed a non-specific probability (so that an action would occasionally happen) I started using a certain way of creating a probability, and I wanted to know if I could determine the exact probability. The way I did this was somewhat as follows:

A random whole number, $a,$ is picked from a set $\lbrace 1,\dots,x\rbrace.$ Another random whole number, $b,$ is picked from a set $\lbrace 1,\dots,y\rbrace.$ If $y$ is greater than $x,$ what is the probability that $a$ will be greater than $b?$

(also, I apologize if this isn't explained/formatted very well; I'm new to this website and I don't know much about typing/explaining complicated math problems)

2

There are 2 best solutions below

0
On

Since $y\gt x,$ the probability that $a$ is greater than $b$ is equal to

\begin{align} \sum_{a=1}^x \Big(\frac{1}{x} \sum_{b=1}^{\min(a-1,y)} \frac{1}{y}\Big)&=\sum_{a=1}^x \Big(\frac{1}{x} \frac{\min(a-1,y)}{y}\Big) \\&=\sum_{a=1}^x \Big(\frac{1}{x} \frac{a-1}{y}\Big) \\&=\frac1{xy}\sum_{a=1}^x(a-1) \\&=\frac1{xy}\frac{(x-1)x}{2} \\&=\frac{x-1}{2y}. \end{align}

0
On

There are $xy$ equally-likely points $(a,b)$, so the probability that $a>b$ is just the number of these points with $a$-coordinate greater than $b$-coordinate, divided by $xy$: $$P(a>b) = \frac{\frac{1}{2}(x-1)x}{xy}=\frac{x-1}{2y}. $$

NB: Just count the points along the successive diagonals as in the following picture, using the fact that $1+2+...+n = \frac{1}{2}n(n+1)$:

enter image description here