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:

*The Gambler’s Ruin Problem:

\(P_{i} = \frac{1-(\frac{q}{p})^{i}}{1-(\frac{q}{p})^{N}}, \text{if}\space p \neq q;\)

\(P_{i} = \frac{i}{N}, \text{if}\space p = q= 0.5\)

- he bets 1 dollar each time (timid strategy).

Chance of winning: 2.03%

```
p <- 0.4
q <- 1-p
i <- 1
N <- 8
round(((1-(q/p)**i))/(1-(q/p)**N),5)
```

`## [1] 0.0203`

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

Assuming he wins each bet he will get: 1, 2 (1st win), 4 (2nd win), 8 (3rd win)

Chance of winning: 6.4%

`p**3`

`## [1] 0.064`

- Which strategy gives Smith the better chance of getting out of jail?

As long as Smith doesn’t get caught gambling in jail which (at least I guess) is frowned upon in jail and thus may very well end up serving more time, then he is better off taking the bold approach as he has a 6.4% chance of winning the 8 dollars he needs to post bail.