Data 605 Assignment Ten

Assignment 10 Data 605

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:

He bets 1 dollar each time (timid strategy)

\[q = 0.6\\ p = 0.4 \\ s = 1 \\ M = 8 \\ \frac{q}{p} = \frac{0.6}{0.4} = 1.5\\ P = \frac{1-(\frac{q}{p})^s}{1-(\frac{q}{p})^M} \\ P = \frac{1-1.5^{1}}{1-1.5^{8}}= .0203\]

Simulation in R

win = 0
lose = 0
cap = 8 
for(game in 1:1000000){
  purse = 1 
  while(purse < cap & purse > 0){ 
    roll = runif(1) 
    if(roll < 0.4){
      purse = purse + 1
    }
    else{
      purse  = purse - 1
    }
    if(purse == 8){ #increment win counter when $8 is reached
      win = win +1
    }
    if(purse == 0){ #increment lose counter when $0 is reached
      lose = lose +1
    }
  }
}
win/lose 
## [1] 0.02077898

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

Mathematically This can be solved as a binomial

dbinom(3,3,0.4) 
## [1] 0.064
#or simply
(.4^3)
## [1] 0.064

Simulation in R

win = 0
lose = 0
cap = 8 
for(game in 1:1000000){
  purse = 1 
  bet = 1 # added in a bet that doubles everytime if the prisoner wins
  while(purse < cap & purse > 0){ 
    roll = runif(1) 
    if(roll < 0.4){
      purse = purse + bet
      bet = 2*bet
    }
    else{
      purse  = purse - bet
    }
    if(purse == 8){ #increment win counter when $8 is reached
      win = win +1
    }
    if(purse == 0){ #increment lose counter when $0 is reached
      lose = lose +1
    }
  }
}
win/lose 
## [1] 0.06864323

Better Strategy

The bold strategy is the better strategy based on both the math and the simulations

Corey Arnouts

April 7, 2019