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).
# for maximum win, the markov chain must be:- state_1: 1, state_2: 2, state_3: 3, state_4: 4, state_5: 5, state_6: 6, state_7: 7, state_8: 8.
p_win <- 0.4
p_loss <- 1 - p_win
state_1 <- 1
state_8 <- 8
timid_strategy <- (1 - ((p_loss/p_win)^state_1)) / (1-((p_loss/p_win)^state_8))
print(paste0("The probability that he wins 8 dollars before losing all of his money if he bets 1 dollar each time is ", timid_strategy))
## [1] "The probability that he wins 8 dollars before losing all of his money if he bets 1 dollar each time is 0.0203013481363997"
# for maximum win, the markov chain must be:- state_1: 1, state_2: 2, state_3: 4, state_4: 8
state_1 <- 1
state_2 <- 2
step_1 <- (1 - ((p_loss/p_win)^state_1)) / (1-((p_loss/p_win)^state_8))
step_2 <- (1 - ((p_loss/p_win)^state_1)) / (1-((p_loss/p_win)^state_8))
step_3 <- (1 - ((p_loss/p_win)^state_1)) / (1-((p_loss/p_win)^state_8))
bold_strategy <- step_1 + step_2 + step_3
print(paste0("The 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 is ", bold_strategy))
## [1] "The 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 is 0.0609040444091991"