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
state_names <- c(0:8)
prob <- matrix(c(1,.6,0,0,0,0,0,0,0,
0,0,.6,0,0,0,0,0,0,
0,.4,0,.6,0,0,0,0,0,
0,0,.4,0,.6,0,0,0,0,
0,0,0,.4,0,.6,0,0,0,
0,0,0,0,.4,0,.6,0,0,
0,0,0,0,0,.4,0,.6,0,
0,0,0,0,0,0,.4,0,0,
0,0,0,0,0,0,0,.4,1), nrow=9, byrow=TRUE)
row.names(prob) <- state_names
colnames(prob) <- state_names
prob
## 0 1 2 3 4 5 6 7 8
## 0 1 0.6 0.0 0.0 0.0 0.0 0.0 0.0 0
## 1 0 0.0 0.6 0.0 0.0 0.0 0.0 0.0 0
## 2 0 0.4 0.0 0.6 0.0 0.0 0.0 0.0 0
## 3 0 0.0 0.4 0.0 0.6 0.0 0.0 0.0 0
## 4 0 0.0 0.0 0.4 0.0 0.6 0.0 0.0 0
## 5 0 0.0 0.0 0.0 0.4 0.0 0.6 0.0 0
## 6 0 0.0 0.0 0.0 0.0 0.4 0.0 0.6 0
## 7 0 0.0 0.0 0.0 0.0 0.0 0.4 0.0 0
## 8 0 0.0 0.0 0.0 0.0 0.0 0.0 0.4 1
plotmat(prob, pos = c(9),
relsize = .9,
lwd = 1, box.lwd = .5,
cex.txt = 0.8,
box.size = 0.03,
box.type = "ellipse",
box.prop = 0.8,
box.col = "light yellow",
box.cex = .8,
dtext = 2,
arr.lwd = .5,
arr.length=.05,
arr.width=.05,
endhead = TRUE,
self.cex = .8,
main = "")
Using the strategy defined on page 9 here
we can see the probabilities starting at each stage:
p = 0.4
q = 0.6
r = q/p
for (i in seq(1, 7 , 1)){
print ((1-r^i)/(1-r^8))
}
## [1] 0.02030135
## [1] 0.05075337
## [1] 0.0964314
## [1] 0.1649485
## [1] 0.267724
## [1] 0.4218874
## [1] 0.6531324
state_names <- c(0:8)
prob <- matrix(c(1,0,0,.6,.6,0,0,0,0,
0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,.6,0,0,
0,0,0,0,0,0,0,0,0,
0,0,0,.4,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,
0,0,0,0,.4,0,.4,0,1), nrow=9, byrow=TRUE)
row.names(prob) <- state_names
colnames(prob) <- state_names
prob
## 0 1 2 3 4 5 6 7 8
## 0 1 0 0 0.6 0.6 0 0.0 0 0
## 1 0 0 0 0.0 0.0 0 0.0 0 0
## 2 0 0 0 0.0 0.0 0 0.0 0 0
## 3 0 0 0 0.0 0.0 0 0.0 0 0
## 4 0 0 0 0.0 0.0 0 0.6 0 0
## 5 0 0 0 0.0 0.0 0 0.0 0 0
## 6 0 0 0 0.4 0.0 0 0.0 0 0
## 7 0 0 0 0.0 0.0 0 0.0 0 0
## 8 0 0 0 0.0 0.4 0 0.4 0 1
plotmat(prob,
relsize = .9,
lwd = 1, box.lwd = 1,
cex.txt = 0.8,
box.size = 0.03,
box.type = "ellipse",
box.prop = 0.8,
box.col = "light yellow",
box.cex = .8,
dtext = 2,
self.cex = .8,
main = "")
not sure exactly how to calculate the probabilities hereโฆ