7. Suppose that I draw two numbers a, b randomly and uniformly from the set \{1,..., N\}, where
a < b. I then randomly select one of a, b and show it to you. You have to guess if it is the larger
of the two numbers or the smaller one. If you guess right, you win... a million dollars!
Obviously, if you guess randomly, your chances of winning are $\frac{1}{2}$. Show that the following
strategy improves your odds of winning.
\begin{itemize}
\item Let X be the number that I show to you, so that X is either a or b, with equal probability.
Randomly pick a number a number $Y \in \{1,2,..., N\}$, independently of the value of X.
\item If $X \ge Y$, guess that X is the largest. Otherwise, guess that X is the smallest.
\end{itemize}
(a) Show that, with this strategy, your chances of guessing right are greater than $\frac{1}{2}$.
[Hint: Define $E := \{X > Y, X = a\} \cup \{X < Y, X = b\}$. Explain why E is the event that
you guess incorrectly. Show that $P(E) < \frac{1}{2}$.]
(b) Use Monte Carlo Simulation to estimate the probability of winning if N = 10.
[Hint: The matlab command R = randsample(1:N, 2, false) will select two different
numbers from 1:N — the term false indicates that it is sampling from the population 1:N
without replacement. Set a = min(R), b = max(R), and then randomly select an X from
[a, b]. Also randomly select a Y from 1:N. Do this a large number M-many times, and see
what proportion of the time it is the case that $(X \ge Y \&\& X == a) \|\ (X < Y \&\& X == b)$.]