Sara and Macey want to play the game of Truth or Dare. They use the following recursive algorithm to decide who goes first:
$\textbf{Algorithm} \hspace{2mm} GoesFirst(k):$
$// \hspace{2mm}k ≥ 1$, the die is fair, and all rolls are independent
Shelly rolls the die, let $s$ be the result;
Macey rolls the die, let $m$ be the result;
$ \textbf{if } s > m \\ \textbf{then} \text{ Sara goes first} \\ \quad \quad return \hspace{2mm} k \\ \textbf{end if } \\ \textbf{if } s < n \\ \textbf{then} \text{ Macey goes first} \\ \quad \quad return \hspace{2mm} k \\ \textbf{end if } \\ \textbf{if } s = m \\ \textbf{then} \text{ GoesFirst(k + 1)} \\ \textbf{end if } \\ $The ladies run algorithm $GoesFirst(1)$, i.e., with $k = 1$. Define the random variable $X$ to be the value of the output of this algorithm. What is the expected value $\mathbb{E}(X)$ of the random variable $X$?
(a) $3/2$
(b) $5/4$
(c) $5/6$
(d) $6/5 \hspace{2mm} \text{ This is the answer} $
Why is this the answer? I know the formula for the expected value is $\mathbb{E}(X) = \sum_{}^{} k \cdot Pr(X = k)$.
From class I learned that the Expected Value of a Geometric Distribution is $1/p$ where $p$ is the probability of success.
Is $5/6$ is the probability of success? (ie. $5/6$ times we will get an answer as to who will go first).
If so, then we repeat this algorithm until we reach a success, which I assume follows the Geometric Distribution:
$\frac{1}{5/6} = 6/5$ which is the answer.
I tried doing the sum but realized it was pointless.
$\mathbb{E}(X) = 1 \cdot 5/6 + 2 \cdot 1/6$ ...
I think my first solution is correct. If anyone can formalize my thinking that would be great.
Thanks.
The algorithm returns the number of the first roll of the die on which they get a different number. As you say, the probability of success (the probability that they roll different numbers) is $5/6.$ The expected number of trials until the first success is $1/p$ as you know. The answer is $6/5$.
It isn't "pointless" to compute the sum. That's how the expected value of $1/p$ is arrived at in the first place. However the second term should be $$2 \cdot 1/6\cdot 5/6$$ It's $2$ times the probability that they get the same number on the first roll, times the probability that they get different numbers on the second.