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 (a) he bets 1 dollar each time (timid strategy).

(1.5^1-1)/(1.5^8-1)
## [1] 0.02030135
win = 0
lose = 0
cap = 8 #
for(game in 1:100000){
  purse = 1 
  while(purse < cap & purse > 0){ 
    roll = runif(1) 
    if(roll < 0.4){
      purse = purse + 1
    }
    else{
      purse  = purse - 1
    }
    if(purse == 8){ 
      win = win +1
    }
    if(purse == 0){ 
      lose = lose +1
    }
  }
}
win/lose 
## [1] 0.02063729
  1. he bets, each time, as much as possible but not more than necessary to bring his fortune up to 8 dollars (bold strategy).
dbinom(3,3,0.4) 
## [1] 0.064
0.4^3
## [1] 0.064
  1. Which strategy gives Smith the better chance of getting out of jail?

He more than triples his probability of winning if he uses the bold strategy. Smith a probability 0.064 of getting out of jail, which is better than the timid strategy which gives him a probability 0.02.