February 18, 2022
It’s time for a random number duel! You and I will both use random number generators, which should give you random real numbers between 0 and 1. Whoever’s number is greater wins the duel!
There’s just one problem. I’ve hacked your random number generator. Instead of giving you a random number between 0 and 1, it gives you a random number between 0.1 and 0.8.
What are your chances of winning the duel?
Probability of winning: 0.45 or 45%
Explanation:
(Note: as we are talking about continuous distributions, the probability that a random variable taking on an exact value is 0, and so less than is the same as less than or equal to; similar for greater. In this write-up I will just use less/greater than or equal to as a convention.)
This puzzle can be solved using conditional probability. Let \(X\) be the random variable representing my number and \(Y\) represent your number. We have the following scenarios given the hack:
Putting everything together:
\begin{align} &P(X \geq Y) \\ \\ =& P(X \geq Y | Y \leq 0.1)P(Y \leq 0.1) \\ &+ P(X \geq Y | Y \geq 0.8)P(Y \geq 0.8) \\ &+ P(X \geq Y | 0.1 \leq Y \leq 0.8)P(0.1 \leq Y \leq 0.8) \\ \\ =& 1 \times 0.1 + 0 \times 0.2 + 0.5 \times 0.7 \\ =& 0.1 + 0.35 \\ =& \boxed{0.45} \\ \end{align}
Here we are assuming both \(X\) and \(Y\) are uniformly distributed.
In general, if the hacker restricts \(X\) to be between \(a\) and \(b\) such that \(0 \leq a \leq b \leq 1\), then the probability of winning becomes:
\begin{align} &P(X \geq Y) \\ \\ =& P(X \geq Y | Y \leq a)P(Y \leq a) \\ &+ P(X \geq Y | Y \geq b)P(Y \geq b) \\ &+ P(X \geq Y | a \leq Y \leq b)P(a \leq Y \leq b) \\ \\ =& 1 \times a + 0 \times (1-b) + 0.5 \times (b-a) \\ =& a + \frac{b-a}{2} \\ =& \boxed{\frac{a+b}{2}} \\ \end{align}
In the puzzle, \(a = 0.1\) and \(b = 0.8\) yields the result of 0.45. In the extreme case where there is no hacking, \(a = 0\) and \(b = 1\) and we once again obtain the probability of winning to be 0.5, as expected.