# Probability of two random number generators producing same number

I have two random number generators, 1 giving me a number between 1 and 5000 (call it x) and the other giving me a number between 1000 and 1500 (call it y). Both including the min and max numbers.

I'm trying to work out the chances of x=y

I'm not sure if it's just (1/5000 * 1/501) - (1/5000 + 1/501) or if there's more to it, any help would be much appreciated.

• Always think about your answer and and ask yourself "does this make sense?" (1/5000 * 1/501) - (1/5000 + 1/501) is a negative number and hence cannot be the correct probability. Dec 24, 2014 at 19:41
• I didn't even try work it out , I just wrote down theory of something we were being taught in school /: P(AnB) = P(A)*P(B) - P(AuB) thanks for the help though Dec 24, 2014 at 19:46
• Be careful with that formula. You need to specify what the events A and B are precisely before going to that formula. I don't think this formula is the way to go though. Dec 24, 2014 at 19:52
• Ok, thanks for the help :) Dec 24, 2014 at 19:56

Let the probability that $X=Y=y$ for a fixed $y$ between $1000$ and $1500$ be $p=\frac{1}{(5000)(501)}$. Then the probability of them being equal is $501p=\frac{1}{5000}$, since the event $X=Y$ is the union of the events $X=Y=y$ for $y$ between $1000$ and $1500$, and each of these smaller events happens with probability $p$.

• So 1/5000 ? Or do I need to divide it by the 501? Dec 24, 2014 at 19:48
• $p$ is the probability of them each being equal to a specific value. The probability of them being equal (which is what you asked for) is $\boxed{1/5000.}$ Dec 24, 2014 at 19:49
• Ah thanks for clearing that up! My heads been frazzled trying work it out Dec 24, 2014 at 19:55

You have $(5000-1)+1=5000$ options for $x$.

You have $(1500-1000)+1=501$ options for $y$.

Hence you have $5000\cdot501$ combinations of $x$ and $y$.

Out of those combinations, you have $501$ options with $x=y$.

Hence the probability of $x$ being equal to $y$ is $\frac{501}{5000\cdot501}=\frac{1}{5000}$.

• @Colum: You're welcome :) Dec 24, 2014 at 20:04

Another way to think about it. Suppose the number from the generator that gives a number between 1000 to 1500 is fixed. Since all those numbers are contained in 1 - 5000, you have a 1/5000 chance of drawing that number in the second generator. This does not change depending on the number you draw in the first generator, hence P(x=y) = 1/5000.

• Ah right that helps clear my head a bit, thanks for the help :) Dec 24, 2014 at 19:58