Posts

Showing posts with the label dynamic programming

Interview problem: dice game

Problem:  (1) Toss a dice. You can get face value in dollars or you can choose to try again twice. What is the expected payoff according to the best strategy? (2) Compare the payoff in (1) to the expectation of the maximum face value of two tosses without calculation. (3) What if you can try again at most 50 times? Estimate the number to the 3 decimal. (4) What if you can try again for infinite times but each toss will cost you 1 dollar? The first toss is free. Solution: (1) Let $f(n)$ be the expected payoff when we can roll at most $n$ times, $f(1)=(1+2+3+4+5+6)/6=3.5$.  For $f(n+1)$, the strategy is to try again if the face value is less than $f(n)$, otherwise take the face value: \begin{equation}f(n+1) = \frac{1}{6}\sum_{i=1}^6\max\left[i, f(n)\right]\,.\tag{1}\end{equation} As a result, $f(2)=(3.5 + 3.5 + 3.5 + 4+5+6) / 6=4.25$. (2) The payoff in (1) should be smaller since we cannot take the face value of the previous roll. (3) We continue to calculate (1): $f(3)=4.67$, $...

Interview problem: Chow-Robbins game

Problem: (1) Let's play a game. You toss a fair coin repeatedly. You can stop whenever you want before reaching 100 times. The payoff is the proportion of heads once stopped or reaching 100 times. What is the expected payoff according to the best strategy? (2) There are a random number of pencils and we two take turns to take the pencils. Each time you or me can take 1 or 2 pencils and whoever get the last one loses. Would you like to play first?  (3) Dicing problem:  (a) Toss a dice. You can get face value in dollars or you can choose to try again twice. What is the expected payoff according to the best strategy? (b) If you can get the maximum face values of two tosses, compare this payoff with that in (a) without calculation. (c) What if you can try again at most 50 times? Estimate the number to the 3 decimal. (d) What if you can try again for infinite times but each toss will cost you 1 dollar. The first toss is free.     Solution: (1) This Chow-Robbins game....