Main Prompt
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
- loses A dollars with probability .6
Find the probability that he wins 8 dollars before losing all of his money if:
Part 1
“he bets 1 dollar each time (timid strategy)”
This is the “Gamblers Ruin Problem”, so
\(P(i) = \frac{1-(\frac{q}{p})^t}{1-(\frac{q}{p})^N}\)
So if he were to bet 1 dollar each time:
p <- 0.4
q <- 0.6
t <- 1
N <- 8
(1-(q/p)^t) / (1-(q/p)^N)
## [1] 0.02030135
Below is a simulation of the described scenario
# We will run the experiment 100K times. Each time, the player will bet 1 dollar.
# If the players total cash on hand reaches 0, we add one to "failed"
# If the players total cash on hand reaches 8, we add one to "released"
# Finally, we can divide released by failed to get our probability
released <- 0
failed <- 0
for (i in seq(1,100000)){
start <- 1
for (i in seq(1,1000)){
if (runif(1)<=0.4) {start = start +1}
else {start = start - 1}
if (start == 0){
failed = failed + 1
break
}
if (start >= 8){
released = released + 1
break
}
}
}
released / failed
## [1] 0.02097074
Part 2
“he bets, each time, as much as possible but not more than necessary to bring his fortune up to 8 dollars (bold strategy).”
So based on the conditions:
bet_number <- c(0, 1, 2, 3)
total_cash <- c(1, 2, 4, 8)
That means that he will need to win three separate times. We know that the probability of winning a given bet is 0.4… therefore, the probability of winning would be
p**3
## [1] 0.064
But we can also simulate this example:
# We will run the experiment 100K times. Each time, the player will bet however many
# dollars he has on him.
# If the players total cash on hand reaches 0, we add one to "failed"
# If the players total cash on hand reaches 8, we add one to "released"
# Finally, we can divide released by failed to get our probability
released <- 0
failed <- 0
for (i in seq(1,100000)){
start <- 1
for (i in seq(1,1000)){
if (runif(1)<=0.4) {start = start + start}
else {start = start - start}
if (start <= 0){
failed = failed + 1
break
}
if (start >= 8){
released = released + 1
break
}
}
}
released/failed
## [1] 0.06791969
Part 3
“Which strategy gives Smith the better chance of getting out of jail?”
The bold stategy provides Smith with a 6.4% chance of escape.
The timid strategy provides Smith with a 2.0% percent chance of escape.
The bold strategy is the better option, although both are pretty bad!