Gambler's Ruin

On each 'turn,' Player A wins $1 from Player B, with the probability specified below. Otherwise, Player B wins $1 from Player A.

A 'game' consists of a series of turns, which continues until one player has all of the money.







Shiny app by Peter Chi
Base R code by Peter Chi
Shiny source files: GitHub Gist
Cal Poly Statistics Dept Shiny Series

        

An application:

In the casino game of blackjack, the house edge dictates that a player will win any given hand against the house with an approximate probability of 0.495 (assuming that the player is playing perfect `basic strategy,' and is not employing any card-counting techniques).

Suppose that a player sits at a blackjack table and plans to bet $1 on every hand, and is willing to lose X dollars overall, but will quit if he is up by Y dollars from his initial fortune, at any moment. Using the inputs above, we can find a simulated probability that he will leave a winner, by putting in X as the initial fortune of Player A, Y as the initial fortune of Player B (the amount that the player wishes to win from the casino), and 0.495 as the probability that Player A wins on any given turn, and then running a large number of games (e.g. 100).

It is rare to find a casino that will actually allow you to bet only $1 on a hand of blackjack; to consider larger bet sizes, we simply need to divide X and Y by the bet size before inputting the initial fortunes.