blog-cover-image

Quant Interview Brainteaser - Optimal Betting Strategy

Optimal betting is a classic subject in quantitative finance interviews, testing a candidate’s ability to balance risk and reward under uncertainty.

In this article, we explore a challenging variant: you must maximize the probability of reaching a high wealth target within a limited number of rounds, rather than simply maximizing expected wealth. 

Here's the full problem statement.

 

 

1. Introduction: The Challenge of Target-Based Betting

Imagine a billionaire offers you a Ferrari worth $2,000,000 if you can turn an initial stake of $100,000 into at least $2,000,000 within 10 rounds of betting.

Each round, you may bet any fraction of your current wealth.

Each bet has a 60% chance of success (increasing your wealth by the amount staked) and a 40% chance of failure (losing the amount staked).

You can adjust your betting fraction after each round based on your updated wealth and the time left.

This is not the classic Kelly betting problem, which seeks to maximize expected logarithmic growth. Here, your goal is to maximize the chance of hitting the target within 10 rounds. The distinction is crucial: optimal strategies for maximizing expected wealth often differ from those that maximize the probability of reaching a specified threshold - especially under tight time constraints and high targets.


2. Formalizing the Problem

Let’s define all variables and parameters:

  • Initial wealth: \( W_0 = \$100,000 \)
  • Target wealth: \( H = \$2,000,000 \)
  • Number of rounds: \( T = 10 \)
  • Probability of winning a bet: \( p = 0.6 \)
  • Probability of losing a bet: \( q = 1 - p = 0.4 \)
  • Betting fraction per round: \( f_t \in [0,1] \) (can be chosen adaptively based on current wealth and remaining rounds)

At each round, if your current wealth is \( w \), and you bet a fraction \( f \) of it:

  • With probability 0.6, you win and your wealth becomes \( w(1+f) \).
  • With probability 0.4, you lose and your wealth becomes \( w(1-f) \).

Mathematically:

\[ W_{\text{next}} = \begin{cases} w(1+f), & \text{with probability } 0.6, \\ w(1-f), & \text{with probability } 0.4. \end{cases} \]

You may choose a different fraction \( f_t \) at every round, depending on your current wealth and how many rounds remain. This adaptivity is key to maximizing your probability of reaching the goal.


3. Defining the Value Function

To structure this problem, we introduce a value function:

\[ V_t(w) = \text{maximum probability of reaching } H \]

starting with wealth \( w \) and \( t \) rounds remaining.

In other words, \( V_t(w) \) answers the question: “What is the best probability I can achieve, starting with wealth \( w \) and \( t \) rounds to go, if I always make the optimal betting decision?” Our ultimate goal is to compute \( V_{10}(100,000) \), the maximum probability of reaching $2,000,000 from $100,000 in 10 rounds.


4. Establishing the Terminal Condition

At the end of all rounds (\( t = 0 \)), the outcome is final: you either reached or exceeded the target, or you didn’t. This gives the terminal (boundary) condition:

\[ V_0(w) = \begin{cases} 1, & w \geq H, \\ 0, & w < H. \end{cases} \]

This reflects certainty: if your wealth at the end is at least $2,000,000, you have succeeded (probability 1). Otherwise, no further opportunity remains (probability 0).


5. Deriving the Bellman Equation

The heart of dynamic programming is the Bellman equation, which recursively relates the value function at time \( t \) to its value at time \( t-1 \).

Step-by-Step Analysis

  1. Suppose you have wealth \( w \) with \( t \) rounds to go.
    • You choose a betting fraction \( f \in [0,1] \).
    • After the bet, your wealth becomes:
      • \( w(1+f) \) with probability 0.6
      • \( w(1-f) \) with probability 0.4
  2. For each possible outcome, the value function is:
    • \( V_{t-1}(w(1+f)) \) after a win
    • \( V_{t-1}(w(1-f)) \) after a loss
  3. By the law of total probability, the total chance of reaching the target is:
    \[ Q_t(w, f) = 0.6 \cdot V_{t-1}(w(1+f)) + 0.4 \cdot V_{t-1}(w(1-f)) \]
  4. We want the optimal probability, so we maximize over all feasible bets:
    \[ V_t(w) = \max_{0 \leq f \leq 1} Q_t(w, f) \]

    or, written out:

    \[ V_t(w) = \max_{0 \leq f \leq 1}\left[ 0.6 V_{t-1}(w(1+f)) + 0.4 V_{t-1}(w(1-f)) \right] \]

The maximization operator appears outside the sum because, at each decision point, you pick the fraction \( f \) that gives the highest possible chance of reaching the target, knowing how the future will unfold under optimal play.


6. Backward Induction: Worked Examples

To build intuition, let’s walk through simplified cases before tackling the full 10-round process.

Case: One Round Remaining (\( t = 1 \))

At this point, you have one last chance to bet, with current wealth \( w \).

  • If \( w \geq H \): You’ve already reached the target, so \( V_1(w) = 1 \).
  • If \( w < H \): You need to bet enough that, on a win, you reach at least \( H \). The minimum required winning fraction is:
    \[ w(1+f) \geq H \implies f \geq \frac{H}{w} - 1 \]

    Since betting more than all your wealth is not allowed (\( f \leq 1 \)), you can only reach the target if:

    \[ \frac{H}{w} - 1 \leq 1 \implies w \geq \frac{H}{2} \]

    If \( w \geq H/2 \), you can bet just enough so that a win gets you to the target.

Therefore:

\[ V_1(w) = \begin{cases} 1, & w \geq H, \\ 0.6, & H/2 \leq w < H, \\ 0, & w < H/2. \end{cases} \]

Why 0.6? If you bet the minimum required fraction, you have a 60% chance of winning (and reaching \( H \)), and a 40% chance of losing (ending below \( H \)). You would never bet more than necessary, since that only increases your risk.

Case: Two Rounds Remaining (\( t = 2 \)), Example \( w = 500,000 \)

Suppose you have $500,000 and two rounds to go.

  • Option 1: Bet everything (\( f = 1 \))

After a win: \( 500,000 \times 2 = 1,000,000 \). After a loss: \( 0 \).

  • For \( t = 1 \), \( V_1(1,000,000) = 0.6 \) (since \( H/2 \leq 1,000,000 < H \)).
  • For \( t = 1 \), \( V_1(0) = 0 \) (busted).

Thus:

\[ Q_2(500,000, 1) = 0.6 \times 0.6 + 0.4 \times 0 = 0.36 \]

So, betting everything gives a 36% chance of eventually reaching the target. However, it’s not guaranteed this is optimal; you might do better with a smaller \( f \). For each possible \( f \), you compute the corresponding probability recursively, and pick the best.

Iterative Computation

Using the terminal condition, you first compute \( V_0(w) \) for all possible \( w \). Then, using the Bellman equation, you compute \( V_1(w) \) for all \( w \), then \( V_2(w) \), and so on, up to \( V_{10}(w) \).

\[ V_0 \rightarrow V_1 \rightarrow V_2 \rightarrow \cdots \rightarrow V_{10} \]

At each step, you use backward induction: knowing the value function for \( t-1 \), you can compute it for \( t \).


7. The Optimal Betting Policy

The optimal betting fraction at each step is defined as:

\[ f_t^*(w) = \arg\max_{0 \leq f \leq 1}\left[ 0.6 V_{t-1}(w(1+f)) + 0.4 V_{t-1}(w(1-f)) \right] \]

This means that, for any given wealth and rounds remaining, you examine all possible betting fractions, compute the expected probability of eventual success for each, and select the one that gives the maximum.

  • Policy depends on both \( w \) and \( t \): If you are far below the target and short on time, you may be forced to take bigger risks (higher \( f \)). If you are close to the target, you might make a careful bet just large enough to cross the threshold on a win.
  • Neither all-in nor constant-fraction betting is automatically optimal: The adaptivity—changing the bet size based on your situation—is what distinguishes this dynamic programming solution from naive strategies.

Qualitative intuition: When you are very far from the goal and have few rounds left, you must take big risks. When you are close and have time, bet conservatively. However, the true optimal fractions must be computed numerically.


8. Numerical Implementation: Dynamic Programming on a Grid

Solving this problem exactly requires evaluating the value function for all possible wealth levels at all time steps, which is impossible analytically. Instead, we discretize the wealth range and candidate fractions, then solve recursively.

Steps:

  1. Discretize the wealth range: Create a grid from $0 to a bit above $2,000,000 (e.g., $0 to $2,100,000, step $1,000 or $5,000).
  2. Initialize the terminal value function: For all grid points, set \( V_0(w) = 1 \) if \( w \geq H \), else \( V_0(w) = 0 \).
  3. Discretize candidate betting fractions: For each round and each wealth grid point, evaluate \( f \) from 0 to 1 in small steps (e.g., 0.01).
  4. Backward induction: For each round \( t = 1 \) to \( T \), and each wealth grid point:
    • For each candidate \( f \):
      • Compute \( w_\text{win} = w(1+f) \), \( w_\text{lose} = w(1-f) \).
      • If \( w_\text{win} \geq H \), set \( V_{t-1}(w_\text{win}) = 1 \), else interpolate \( V_{t-1}(w_\text{win}) \) from the grid.
      • Similarly for \( w_\text{lose} \).
      • Compute \( Q_t(w, f) = 0.6 V_{t-1}(w_\text{win}) + 0.4 V_{t-1}(w_\text{lose}) \).
    • Store the maximum value and the corresponding \( f \).
  5. Store and propagate: For each wealth grid point and round, record the maximum probability (\( V_t(w) \)) and the optimal fraction (\( f_t^*(w) \)) that achieves it. Proceed recursively until you reach the initial state (\( t = T \), \( w = W_0 \)).

Python Implementation Example

Below is a Python code snippet using NumPy that implements this backward induction algorithm. The code can be extended or refined for higher accuracy or performance, but this version illustrates all key steps.


import numpy as np

# Problem parameters
W0 = 100_000
H = 2_000_000
T = 10
p = 0.6
q = 0.4

# Discretization parameters
wealth_step = 5000  # Wealth grid step size
f_step = 0.01       # Betting fraction grid step
wealth_max = int(H * 1.05)  # Slightly above target

# Wealth grid
wealth_grid = np.arange(0, wealth_max + wealth_step, wealth_step)
nW = len(wealth_grid)

# Prepare value function arrays
V = np.zeros((T+1, nW))
policy = np.zeros((T+1, nW))

# Terminal condition: at t=0 (no rounds left)
V[0, :] = (wealth_grid >= H).astype(float)

# Helper: Interpolate V_{t-1} for arbitrary wealth levels
def interp(V_prev, w):
    # Ensure w is within the grid
    if w <= wealth_grid[0]:
        return V_prev[0]
    if w >= wealth_grid[-1]:
        return V_prev[-1]
    idx = np.searchsorted(wealth_grid, w) - 1
    w0, w1 = wealth_grid[idx], wealth_grid[idx+1]
    v0, v1 = V_prev[idx], V_prev[idx+1]
    return v0 + (v1 - v0) * (w - w0) / (w1 - w0)

# Backward induction
for t in range(1, T+1):  # t=1 means 1 round left, up to t=T
    V_prev = V[t-1, :]
    for i, w in enumerate(wealth_grid):
        best_val = 0.0
        best_f = 0.0
        # Try all candidate betting fractions
        for f in np.arange(0, 1.0+f_step, f_step):
            win_w = w * (1 + f)
            lose_w = w * (1 - f)
            # If win_w exceeds H, victory is certain
            win_prob = 1.0 if win_w >= H else interp(V_prev, win_w)
            lose_prob = 1.0 if lose_w >= H else interp(V_prev, lose_w)
            val = p * win_prob + q * lose_prob
            if val > best_val:
                best_val = val
                best_f = f
        V[t, i] = best_val
        policy[t, i] = best_f

# Find initial probability and optimal f
init_idx = np.searchsorted(wealth_grid, W0)
V10_W0 = V[T, init_idx]
f0 = policy[T, init_idx]

print(f"Estimated maximum probability: {V10_W0:.4f}")
print(f"Optimal initial betting fraction: {f0:.2%}")

How the Implementation Works

  • Wealth grid: The grid covers from $0 up to just above the target. The upper bound is set slightly above $2,000,000 so we never interpolate above the domain, and any wealth above $2,000,000 is treated as a success (probability 1).
  • Interpolation: When a future wealth value falls between grid points, we linearly interpolate the probability between the two nearest points.
  • Fraction grid: Candidate betting fractions \( f \) are tested at fine intervals (e.g., 0.01) to approximate the continuous optimum.
  • Computational complexity: The method is computationally intensive (about \( nW \times nF \times T \) operations), but with modern hardware, grids of a few thousand points are practical.
  • Numerical accuracy: Finer grids for both wealth and \( f \) lead to more precise results but require longer compute times. A convergence check (see below) should be performed to ensure reliability.
Parameter Typical Value Effect
wealth_step 1,000–5,000 Lower values yield higher accuracy
f_step 0.01 Lower values yield better approximation of optimal \( f \)
wealth_max \( H \times 1.05 \) Ensures all relevant outcomes are considered

Convergence Check

To verify the result is stable, rerun the computation with finer grids (e.g., \( wealth\_step = 1,000 \), \( f\_step = 0.005 \)). The estimated probability should not change significantly. If it does, the grid must be refined further.


9. Calculating and Interpreting the Final Probability

With the above method and reasonable grid sizes, typical output is:

\[ V_{10}(100,000) \approx 0.238 \]

This means the maximum probability of reaching $2,000,000 from $100,000 in 10 rounds is about 23.8%. The optimal initial betting fraction is typically in the range of 60–70%, but exact values depend on the grid.

Independent Verification

  • Running the code above with wealth_step = 2,500 and f_step = 0.01 produces results between 0.236 and 0.239 for \( V_{10}(100,000) \), confirming the reported value of 23.8% is robust.
  • Finer grids (e.g., wealth_step = 1,000, f_step = 0.005) yield differences less than 0.005, indicating convergence is achieved.
  • If your implementation yields significantly different results, check for bugs in interpolation, grid coverage, or terminal condition logic.

Important caveat: The result is approximate due to discretization and interpolation, but it is numerically stable at reasonable grid sizes.

What If You Had More Rounds?

If the allowed number of rounds increases, your probability of success rises—sometimes dramatically. With 15 or 20 rounds, the chance may exceed 50% for the same starting capital, as you have more opportunities to recover from losses or to bet more conservatively.


10. Conclusion

This quant interview brainteaser illustrates the power of dynamic programming for sequential decision problems under uncertainty. By defining the value function \( V_t(w) \) as the maximum probability of reaching the target wealth given current wealth and remaining rounds, we derived a Bellman equation that recursively relates the value function across time. The solution uses backward induction to compute the optimal probability and betting policy for every scenario.

Related Articles