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 0.4 and loses A dollars with probability 0.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?
If he bets 1 dollar each time (timid strategy).
timid = function() {
p = numeric(9)
p[1] = 0
p[9] = 1
for (iter in 1:10000) {
for (j in 2:8) {
p[j] = 0.4 * p[j + 1] + 0.6 * p[j - 1]
}
}
return(p[2])
}
timid_p = timid()
cat("The Probability of Smith getting out of jail using timid strategy is", timid_p,"or", timid_p *100, "% \n")
## The Probability of Smith getting out of jail using timid strategy is 0.02030135 or 2.030135 %
If he bets, each time, as much as possible but not more than necessary to bring his fortune up to 8 dollars (bold strategy).
bold = function() {
p = numeric(9)
p[1] = 0
p[9] = 1
for (iter in 1:10000) {
for (j in 2:8) {
A = min(j, 8 - j)
if (j + A <= 8 && j - A >= 1) {
p[j] = 0.4 * p[j + A] + 0.6 * p[j - A]
} else if (j + A > 8) {
p[j] = 0.4 * p[8] + 0.6 * p[j - A]
} else if (j - A < 1) {
p[j] = 0.4 * p[j + A] + 0.6 * p[1]
}
}
}
return(p[2])
}
bold_p = bold()
cat("The probability of Smith getting out of jail using bold strategy is", bold_p,"or", bold_p*100,"%\n")
## The probability of Smith getting out of jail using bold strategy is 0 or 0 %
Which strategy gives Smith the better chance of getting out of jail?
if (timid_p > bold_p) {
cat("The timid strategy gives Smith a better chance of getting out of jail.")
} else {
cat("The bold strategy gives Smith a better chance of getting out of jail.")
}
## The timid strategy gives Smith a better chance of getting out of jail.