Riddler Express: February 18, 2022

David Ding

February 18, 2022

Hacking Distributions

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:

  1. If given \(Y \leq 0.1\), then \(X \geq Y\) for sure as \(X\) ranges from 0.1 to 0.8.
  2. If given \(Y \geq 0.8\), then \(X \leq Y\) for sure for the same reason as above.
  3. If given \(0.1 \leq Y \leq 0.8\), then it's a toss-up on who will win (i.e. \(X\) will win 50% of the time).

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.

Generalization

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.