Let \(P_n\) as the probability of winning $8 before losing all of the money when Smith has \(n\) dollars.

  1. Timid Strategy: Smith bets $1 each time.
  2. Bold Strategy: Smith bets as much as possible but not more than necessary to bring his fortune up to $8.

For the timid strategy, Smith bets $1 each time.

\(P_n = 0.4 \times P_{n+1} + 0.6 \times P_{n-1}\) for \(1 \leq n \leq 7\), \(P_0 = 0\) (no money to bet), \(P_8 = 1\) (enough money to get out of jail).

bold strategy, Smith bets as much as possible to reach $8 without exceeding it. Let \(m\) be the amount he bets when he has \(n\) dollars. \(m = \min(n, 8-n)\).

\(P_n = 0.4 \times P_{n+m} + 0.6 \times P_{n-m}\) for \(1 \leq n \leq 7\), with boundary conditions: \(P_0 = 0\), \(P_8 = 1\).

  1. Bold Strategy:
  1. The bold strategy gives Smith a better chance of getting out of jail since under the timid strategy, \(P_7 = 0.4\), but under the bold strategy, \(P_4 = 1\).
P <- matrix(c(0, 0.6, 0.4, 0, 0, 0, 0, 0, 0,
              0, 0, 0.6, 0.4, 0, 0, 0, 0, 0,
              0, 0, 0, 0.6, 0.4, 0, 0, 0, 0,
              0, 0, 0, 0, 0.6, 0.4, 0, 0, 0,
              0, 0, 0, 0, 0, 0.6, 0.4, 0, 0,
              0, 0, 0, 0, 0, 0, 0.6, 0.4, 0,
              0, 0, 0, 0, 0, 0, 0, 0.6, 0.4,
              0, 0, 0, 0, 0, 0, 0, 0, 1,
              0, 0, 0, 0, 0, 0, 0, 0, 1), nrow=9, byrow=TRUE)

prob_win_8_dollars <- P[2, 9]^100  

P_bold <- P

for (i in 1:100) {
  for (j in 2:8) {
    bet_size <- min(j - 1, 8 - j)
    P_bold[j, j + bet_size] <- P_bold[j, j + bet_size] + P[j, j]
    P_bold[j, 1] <- P_bold[j, 1] + P[j, j]
  }
}

prob_win_8_dollars_bold <- P_bold[2, 9]^100  


if (prob_win_8_dollars > prob_win_8_dollars_bold) {
  cat("Timid strategy has a better chance of getting out of jail.\n")
} else if (prob_win_8_dollars < prob_win_8_dollars_bold) {
  cat("Bold strategy has a better chance of getting out of jail.\n")
} else {
  cat("Both strategies have the same chance of getting out of jail.\n")
}
## Both strategies have the same chance of getting out of jail.
cat("Probability of winning 8 dollars (Timid Strategy):", prob_win_8_dollars, "\n")
## Probability of winning 8 dollars (Timid Strategy): 0
cat("Probability of winning 8 dollars (Bold Strategy):", prob_win_8_dollars_bold, "\n")
## Probability of winning 8 dollars (Bold Strategy): 0