Katkat

Analyze an Unfair-Coin Bankroll Game

OptiverSoftware Engineer · Technical Screen

Last updated

This problem tests probability theory and expected value calculations in the context of a game with an unfair coin and a bankroll constraint.

The Problem

You start with an initial bankroll of B = 10. You play a game where you flip a biased coin that lands on heads with probability p and tails with probability 1-p.

For every heads, you win 1 unit. For every tails, you lose 1 unit. You continue playing until you either go broke (bankroll hits 0) or reach a target bankroll of N = 20.

Task

  1. Derive the mathematical formula for the probability of reaching the target N before going broke, starting from B.
  2. Calculate the specific probability if p = 0.6.
  3. Discuss how the probability changes if the game is "fair" (p = 0.5) versus "unfair" (p = 0.6).

Constraints & Notes

  • Assume p is constant throughout the game.
  • The game ends immediately if the bankroll reaches 0 or N.
  • Provide the general solution for any p where p != 0.5.

Hints

Hint 1

Let P(x) be the probability of reaching N starting from bankroll x, and express P(x) as a recurrence relation: P(x) = p*P(x+1) + (1-p)*P(x-1).

Hint 2

Recognize that this is a linear homogeneous recurrence relation with constant coefficients, with boundary conditions P(0) = 0 and P(N) = 1.

Hint 3

For the case where p != 0.5, the solution follows the form P(x) = (1 - ((1-p)/p)^x) / (1 - ((1-p)/p)^N).

Follow-up questions

  • How does the result change if you are not allowed to go to negative bankrolls, but you lose your entire current bankroll if you lose a flip (i.e., a doubling game)?
  • If p = 0.5, the formula derived for p != 0.5 results in a division by zero; how do you derive the probability of reaching the target for a fair coin?
  • Suppose the house takes a small fee of 0.05 units every flip; how does this 'tax' affect the expected duration of the game?