Problem 1

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

(a) He bets 1 dollar each time (timid strategy)

p = 0.4
q = 0.6
z = 1
m = 8


timid_p = round(((1-(q/p)^z) / (1-(q/p)^m)), 4)

cat("The probability that he wins 8 dollars before losing all of his money if he bets a dollar each time is ", timid_p)
## The probability that he wins 8 dollars before losing all of his money if he bets a dollar each time is  0.0203

(b) He bets, each time, as much as possible but not more than necessary to bring his fortune up to 8 dollars (bold strategy)

bold_p = round(dbinom(3, 3, 0.4), 4)
cat("The probability that he wins 8 dollars before losing all of his money if he bets all each time is ",bold_p)
## The probability that he wins 8 dollars before losing all of his money if he bets all each time is  0.064

(c) Which strategy gives Smith the better chance of getting out of jail?

p = 0.4
q = 0.6
z = 1
m = 8
#Probability that he wins 8 dollars before losing all of his money if He bets 1 dollar each time (timid strategy)
timid_p = round(((1-(q/p)^z) / (1-(q/p)^m)), 4)

#Probability that he wins 8 dollars before losing all of his money 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_p = round(dbinom(3, 3, 0.4), 4)

#Probability ratio between timid and bold strategy
ratio = round(bold_p/timid_p)

cat("The Bold strategy gives Smith approximately ", ratio, " times chances of getting out of the jail")
## The Bold strategy gives Smith approximately  3  times chances of getting out of the jail