#### Elina Azrilyan

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).

Solution:

Let’s use the formula from Chapter 12.2 “GAMBLER’S RUIN”.

p <- 0.4
q <- 0.6
z <- 1
M <- 8

prob <- ((q/p)^z - 1)/((q/p)^M - 1)
prob
## [1] 0.02030135
##### (b) he bets, each time, as much as possible but not more than necessary to bring his fortune up to 8 dollars (bold strategy).

Solution:

Let’s set up a 5x5 matrix for the Markov chain for this scenatio. We have the possible outcomes of 0,1,2,4,8 and there is what the probabilities look like:

tmatrix <- matrix(c(1,0,0,0,0,0.6,0,0.4,0,0,0.6,0,0,0.4,0, 0.6, 0, 0, 0, 0.4,0,0,0,0,1), nrow=5, byrow=TRUE)
tmatrix
##      [,1] [,2] [,3] [,4] [,5]
## [1,]  1.0    0  0.0  0.0  0.0
## [2,]  0.6    0  0.4  0.0  0.0
## [3,]  0.6    0  0.0  0.4  0.0
## [4,]  0.6    0  0.0  0.0  0.4
## [5,]  0.0    0  0.0  0.0  1.0
init <- c(0,1,0,0,0)
p2<-init%*%tmatrix
p2
##      [,1] [,2] [,3] [,4] [,5]
## [1,]  0.6    0  0.4    0    0
p3<- p2 %*% tmatrix
p3
##      [,1] [,2] [,3] [,4] [,5]
## [1,] 0.84    0    0 0.16    0
p4<- p3 %*% tmatrix
p4
##       [,1] [,2] [,3] [,4]  [,5]
## [1,] 0.936    0    0    0 0.064
##### (c) Which strategy gives Smith the better chance of getting out of jail?

Solution:

The bold strategy gives a higher chance of success -0.064 - than the timid strategy - 0.02 (I wonder if there is a life lesson somewhere in this problem - not about gambling though).