Honors Project
I have worked with Gambler’s Ruin problem in Fall 2016 as part of my Probability & Statistics Honors project. I have solved the problem using Markov’s Chain.
Gambler’s Ruin Problem
Let N ≥ 2 be an integer and let 1 ≤ i ≤ N – 1. Consider a gambler who starts with an initial fortune of $i and then on each successive gamble either wins $1 or loses $1 independent of the past with probabilities p and q = 1 – p respectively. Let Xn denote the total fortune after the nth gamble. The gambler’s objective is to reach a total fortune of $N, without first getting ruined (running out of money). If the gambler succeeds, then the gambler is said to win the game. In any case, the gambler stops playing after winning or getting ruined, whichever happens first {Xn} yields a Markov chain (MC) on the state space S = {0, 1, · · · , N}.
The transition probabilities are given by ,
, 0 ≤ i ≤ N, and both 0 and N are absorbing states,
= 1. For example, when N = 4 the transition matrix is given by,
While the game proceeds, this MC forms a simple random walk, ; where
forms an i.i.d. sequence of r.v.s. distributed as, P(
= 1) = p, P(
= -1) = q = 1 – p, and represents the earnings on the successive gambles. Since the game stops when either
or
= N, let
, denote the time at which the game stops when
. If
= N, then the gambler wins, if
= 0, then the gambler is ruined.
Let denote the probability that the gambler wins when
.
denotes the probability that the gambler, starting initially with $i, reaches a total fortune of N before ruin; 1 –
is thus the corresponding probability of ruin. Clearly
and
= 1 by definition, and we next proceed to compute
Let
, that is, we suppress the dependence on N for ease of notation. The key idea is to condition on the outcome of the first gamble,
= 1 or
= -1, yielding
The derivation of this recursion is as follows: If = 1, then the gambler’s total fortune increases to
and so, by the Markov property the gambler will now win with probability
. Similarly, if
, then the gambler’s fortune decreases to
and so by the Markov property the gambler will now win with probability,
. The probabilities corresponding to the two outcomes are p and q yielding (2). Since p + q = 1, (2) can be re-written as p
=
, yielding
In particular, = (
) = (
(since
= 0), so that
= (
) = (
, and more generally
= (
,
. Thus,
yielding,
(1)
(Here we are using the “geometric series” equation =
, for any number a and any integer
)
Choosing i = N – 1 and using the fact that yields,
(2)
from which we conclude that,
(3)
thus obtaining from (3) (after algebra) the solution,
(4)
Code Magic
CodeMagic is an Android app that teaches elementary school students how to code using animation and etc. This should include Blockly to teach them Javascript and Python. Games and levels are going to be added gradually. Anyone is welcome to give new game ideas or add certain levels.