This assignment uses random number generation, so I am setting a seed for consistent results:
set.seed(149162536)
Smith is in jail and has 1 dollar; he can get out on bail if he has 8 dollars. A guard agrees to make a series of bets with him. If Smith bets A dollars, he wins A dollars with probability .4 and loses A dollars with probability .6. Find the probability that he wins 8 dollars before losing all of his money if
he bets 1 dollar each time (timid strategy).
he bets, each time, as much as possible but not more than necessary to bring his fortune up to 8 dollars (bold strategy).
Which strategy gives Smith the better chance of getting out of jail?
We can model this approach using The Gambler’s Ruin. Smith’s “stake” is \(s=1\) dollar. We define \(q_z\) as the probability that Smith loses all of his money before reaching \(M=8\) with a stake of \(z\). Then:
\(q_1=\frac{(q/p)^M-(q/p)^z}{(q/p)^M-1}=\frac{(.6/.4)^8-(.6/.4)^1}{(.6/.4)^8-1}=\frac{(1.5)^8-1.5}{1.5^8-1}=0.9796987\)
In other words, Smith will lose the game with a probability of 0.9796987, and will win the game with a probability of \(1-0.9796987=0.0203013\), approximately a 2.03% chance of winning.
I will use R to replicate these results. First, we write a function to play the game one time:
timid_strategy <- function(timid_starting, timid_win_prob, timid_goal) {
timid_smith_wealth <- timid_starting
while (timid_smith_wealth < timid_goal & timid_smith_wealth > 0) {
rand <- runif(1)
if (rand <= 1 - timid_win_prob) {timid_smith_wealth = timid_smith_wealth - 1} else {timid_smith_wealth = timid_smith_wealth + 1}
}
if (timid_smith_wealth == 0) {timid_game_status <<- "Lose"}
if (timid_smith_wealth == timid_goal) {timid_game_status <<- "Win"}
}
Now we use a for loop to play the game 1,000,000 times:
timid_results <- c("")
for (i in 1:1000000) {
timid_strategy(1, 0.4, 8)
timid_results[i] <- timid_game_status
}
p_timid_win = sum(timid_results == "Win") / 1000000
p_timid_win
## [1] 0.020197
This simulation results in a win probability of 0.020197, extremely close to the calculated value of 0.0203013.
The wording of the problem makes it seem more complicated than it is. There are only four ways this can play out:
Smith bets a dollar on his first bet and loses, ending the game. This outcome occurs with probability \(P(A)=0.6\)
Smith bets a dollar on his first bet and wins, going up to $2. He then bets $2 on his next bet and loses, ending the game. This outcome occurs with probability \(P(B)=0.4 \times 0.6=0.24\)
Smith bets a dollar on his first bet and wins, going up to $2. He then bets $2 on his next bet and wins, going up to $4. He then bets $4 on his next bet and loses, ending the game. This heartbreaking outcome occurs with probability \(P(C)=0.4 \times 0.4 \times 0.6 = 0.096\)
Smith bets a dollar on his first bet and wins, going up to $2. He then bets $2 on his next bet and wins, going up to $4. He then bets $4 on his next bet and wins, going up to $8 and ending the game. This outcome occurs with probability \(P(D)=0.4 \times 0.4 \times 0.4=0.064\)
All four probability calculations are clearly correct, and the sum of all of these probabilities is \(0.6+0.24+0.096+0.064=1\), demonstrating that there are no other possible outcomes.
Therefore, the probability that the Bold Strategy wins Smith his freedom is 0.064, or 6.4%
I will use R to replicate these results. First, we write a function to play the game one time:
bold_strategy <- function(bold_starting, bold_win_prob, bold_goal) {
bold_smith_wealth <- bold_starting
while (bold_smith_wealth < bold_goal & bold_smith_wealth > 0) {
rand <- runif(1)
if(bold_smith_wealth > bold_goal / 2) {bold_smith_bet <- bold_goal - bold_smith_wealth} else {bold_smith_bet = bold_smith_wealth}
if (rand <= 1 - bold_win_prob) {bold_smith_wealth = bold_smith_wealth - bold_smith_bet} else {bold_smith_wealth = bold_smith_wealth + bold_smith_bet}
}
if (bold_smith_wealth == 0) {bold_game_status <<- "Lose"}
if (bold_smith_wealth == bold_goal) {bold_game_status <<- "Win"}
}
Now we use a for loop to play the game 1,000,000 times:
bold_results <- c("")
for (j in 1:1000000) {
bold_strategy(1, 0.4, 8)
bold_results[j] <- bold_game_status
}
p_bold_win = sum(bold_results == "Win") / 1000000
p_bold_win
## [1] 0.063795
This simulation results in a win probability of 0.063795, extremely close to the calculated value of 0.064.
Bold.