Assignment

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.

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

Calculation 1 - Manual

According to formula of Gambler’s Ruin: \[ P = \frac{1 - (\frac{q}{p})^s}{1 - (\frac{q}{p})^M} \\ P = \frac{1 -(\frac{0.6}{0.4})^1}{1 - (\frac{0.6}{0.4})^8} \\ P = 0.02 \]

Calculation 2 - R code

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

# Calculate the probability of reaching M before reaching 0
p_z1 <- 1 - ((q/p)^M - (q/p)^z)/((q/p)^M - 1)
p_z1
## [1] 0.02030135

Calculation 3 - Simulated R code referenced from grp.gameplay - R Documentation

#install.packages("gamblers.ruin.gameplay")
library(gamblers.ruin.gameplay)
#grp.gameplay(ini.stake, p, win.amt)
#init.stake: the initial capital (money) with which the gambler enters the game.
#p: the probability with which the gambler wins each round of the game, 0<p<1.
#win.amt: the amount of money which the gambler desires to win from the game.

bets <- grp.gameplay(1,0.4,8)
bets

The probability that Smith reaches \(8 dollars\) without ever having reached \(0\) while using the timid strategy is \(0.02\) or \(2\)%.

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

# create transition probability matrix
P <- matrix(rep(0,25), nrow=5, ncol=5)
P[1,1] <- 1
P[5,5] <- 1

for (i in 2:4) {P[i,i-1] <- 0.6
    P[i,i+1] <- 0.4}
P
##      [,1] [,2] [,3] [,4] [,5]
## [1,]  1.0  0.0  0.0  0.0  0.0
## [2,]  0.6  0.0  0.4  0.0  0.0
## [3,]  0.0  0.6  0.0  0.4  0.0
## [4,]  0.0  0.0  0.6  0.0  0.4
## [5,]  0.0  0.0  0.0  0.0  1.0
library(expm)
# probability vector, (0,1,0,0,0), represents the starting distribution
# final distribution of the probability vector after 4 steps
c(0,1,0,0,0)%*%(P%^%4)
##       [,1]   [,2] [,3]   [,4]  [,5]
## [1,] 0.744 0.1152    0 0.0768 0.064

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

Smith has a better chance of getting out of jail with the bold strategy, \(0.064\) than with the timid strategy, \(0.02\).