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
# create a function to see if Smith can win
solve_p <- function(p){
q <- 1-p
n <- 1
end_goal <- 8
(1 - (q/p)^n) / (1 - (q/p)^end_goal)
}
# winning chance
p <- 0.4
win_prob <- solve_p(p)
win_prob
## [1] 0.02030135
win_3_time <- p * p * p
win_3_time
## [1] 0.064
The best strategy for Smith to get out of jails is to place a larger bet since his chance of winning is higher than half.