Interview Question on Probability: A and B toss a dice with 1 to n faces in an alternative way

1.2k Views Asked by At

A and B toss a dice with 1 to n faces in an alternative way, the game is over when a face shows up with point less than the previous toss and that person loses. What is the probability of the first person losing the game and the expected number of tosses?

I can solve this question for 6 face dice: If the first die is 1, there are 5 greater numbers on the second: 1/6 * 5/6 = 5/36. If the first die is 2, there are 4: 1/6 * 4/6 = 4/36 and so on. T/hus prob of first person losing the game is:

5/36 + 4/ 36 + 3/36 + 2/36 + 1/36 = 15/36 = 5/12

don't know how to generalize it to n faces.

2

There are 2 best solutions below

6
On BEST ANSWER

There are $\binom{n+k-1}k$ different non-decreasing sequences of length $k$ with elements in $\{1,\ldots,n\}$. The first player loses exactly if for any even $k$ the first $k$ rolls form such a sequence and the first $k+1$ rolls don't. Thus the probability for the first player to lose is

$$ \sum_{k=0}^\infty(-1)^k\binom{n+k-1}k\frac1{n^k}=\left(1+\frac1n\right)^{-n}\;. $$

This goes to $\mathrm e^{-1}$ as $n\to\infty$. In the limit $n\to\infty$, the probability for equal rolls goes to zero, so we can rank the rolls. If we rank the first $k$ rolls, the ranks are a random permutation of the first $k$ integers. Thus, the limit can also be obtained if we know how many permutations have their first descent (or, equivalently, ascent) in an even position. This was recently asked and answered at Permutations of length $n$ in which the first ascent occurs in an even position. The result is that the number of these permutations is the number of derangements, and the proportion of permutations of length $k$ that are derangements goes to $\mathrm e^{-1}$ as $k\to\infty$, in agreement with the above result.

The expected number of rolls can be obtained by summing the probabilities that no descent has occurred after $k$ rolls:

$$ \sum_{k=0}^\infty\binom{n+k-1}k\frac1{n^k}=\left(1-\frac1n\right)^{-n}\;. $$

This goes to $\mathrm e$ as $n\to\infty$. In the limit $n\to\infty$, we can again ignore the possibility of equal rolls. The probability that no descent has occurred after $k$ rolls is then $\frac1{k!}$, and the expected number of rolls is

$$ \sum_{k=0}^\infty\frac1{k!}=\mathrm e\;, $$

in agreement with the above result.

2
On

Let me get you started. For $k=1,2,\dots,n$ let $p_k$ be the probability that the roller loses if he rolls $k,$ and that does not immediately win the game. Therefore, the probability that the first player loses is $${1\over n}\sum_{k=1}^np_k$$

It seems to me that the easiest way to compute $p_k$ will be in decreasing order, starting with $k=n$ and progressing down to $k=1$. When $k= n$ we have

$$p_n= {n-1\over n} + {1\over n}\left(1-p_n\right)\implies p_n={n\over n+1}$$ because, if the roller rolls $n$, he will lose if his opponent rolls anything but $n$, and in the case where the opponent does rolls $n$, he loses if the opponent doesn't lose.

Similarly, $$ \begin{align} p_{n-1}&={n-2\over n} + {1\over n}\left(1-p_{n-1}\right) + {1\over n}\left(1-p_n\right)\\ p_{n-1}&=1-{1\over n}p_{n-1}-{1\over n}p_n\\ {n+1\over n}p_{n-1}&=1-{1\over n+1}\\ p_{n-1}&={n^2\over(n+1)^2} \end{align} $$

Can you continue?

EDIT

Now that a complete solution has been given, I will work out the details. I claim that with $p_k$ defined as above, we have $$p_{n-j}=\left({n\over n+1}\right)^{n-j},\ j=0,1,\dots,n-1$$

The $j=0$ case has been done above. Assuming the theorem is true for $0,1,\dots,j-1,$, we have $$ \begin{align} p_{n-j}&={n-j-1\over n}+{1\over n}\sum_{k=n-j}^n(1-p_k)\\ \left(1+\frac1n\right)p_{n-j}&=1-\frac1n\sum_{k=0}^{j-1}p_{n-k}\\ \left({n+1\over n}\right)p_{n-j}&=1-\frac1n\sum_{k=0}^{j-1}\left({n\over n+1}\right)^{k+1}\\ \left({n+1\over n}\right)p_{n-j}&=1-\frac1n\frac{\left({n\over n+1}\right)^{j+1}-{n\over n+1}}{{n\over n+1}-1}\\ \left({n+1\over n}\right)p_{n-j}&=1-\frac1n{n\over n+1}\frac{\left({n\over n+1}\right)^{j}-1}{{-1\over n+1}}=1-\left(1-\left(n\over n+1\right)^j\right)\\ p_{n-j}&=\left({n\over n+1}\right)^{j+1} \end{align} $$

Therefore, the probability that the first player loses is $$ \frac1n\sum_{j=0}^{n-1}\left({n\over n+1}\right)^{j+1}= \frac1n\frac{\left({n\over n+1}\right)^{n+1}-{n\over n+1}}{{n\over n+1}-1}=\frac1n{n\over n+1}\frac{\left({n\over n+1}\right)^n-1}{{-1\over n+1}}=1-\left({n\over n+1}\right)^n$$

Note that this is precisely the complement of the probability that joriki computed in his solution. The problem lies in the description of the game in the question: "the game is over when a face shows up with point less than the previous toss and that person loses." It isn't at all clear who "that person" is, as the phrase has no antecedent. I interpreted it to mean that the first player who rolls a smaller number wins, and joriki interpreted it oppositely. Note that joiki says that the first player loses if the first non-monotonically increasing sequence has odd length, so that if the first $3$ rolls are $3,4,2$ the first player loses. In my interpretation, since it is the first player who rolled the $2,$ the first player wins. It's a bit surprising that nobody (including joriki and me) noticed that we were using different rules.

A similar approach will give the expected number of rolls, and this time, reassuringly, I get the same answer as joriki. If we let $e_k$ be the expected number number of rolls remaining, if the current point is $k$ then the expected number of rolls in the game is $$E=1+\frac1n\sum_{k=1}^ne_k$$ and in a manner exactly analogous to the calculations above, we find that $$e_{n-j}=\left(n\over n-1\right)^{j+1},\ j=0,1,\dots,n-1$$ and that $$E=\left({n\over n-1}\right)^n=\left(1-\frac1n\right)^{-n}$$