Lecture Random Walks and Diff Eq PDF
Lecture Random Walks and Diff Eq PDF
random walks
In this lecture we discuss how to solve linear difference equations and give several
applications.
First order homogeneous equation: Think of the time taking integer values n =
0, 1, 2, · · · and qn describing the state of some system at time n. We consider an equation
of the form
where qn , n = 0, 1, 2, 3, · · · are unknown and a and b are fixed constants. This equation
is called a first order homogeneous equation. To solve it we rewrite it as
−b
qn = qn−1 = αqn−1
a
So if we are given q0 , e.g. the state of the system at time 0, then the state of the system
at time n is given by qn = αn q0 , i.e. this is a model for exponential growth or decay.
To summarize
1
and so after 5 year we have with q0 = 1000
60
241
q60 = 1000 = 1283.35
240
cn = c , cn = cn , cn = cαn .
This equation is called inhomogeneous because of the term cn . The following simple fact
is useful to solve such equations
Linearity principle: Suppose q̂n be a solution of the inhomogeneous aqn + bqn−1 = cn
and q̃n be a solution of the homogeneous equation aqn +bqn−1 = 0 then qn + q̃n is a solution
of the inhomegenous equation aqn + bqn−1 = cn . Indeed we have
aq̂n + bq̂n−1 = cn
aq̃n + bq̃n−1 = 0
• Find the general solution of the homogeneous equation. This solution has a free
constant in it which we then determine using for example the value of q0 .
• The general solution of the inhomogeneous equation is the sum of the particular
solution of the inhomogeneous equation and general solution of the homogeneous
equation.
2
Example: Solve
aqn + bqn−1 = c
i.e., the inhomegenous term is cn = c i.e. constant. We look for a particular solution, and
after some head scratching we try qn = d to be constant and find
c
ad + bd = c , or d =
a+b
The general solution is then
c
qn = C(−b/a)n + .
a+b
Example: Solve
2qn − qn−1 = 2n , q0 = 3
The solution of the homogenous is q n = C(1/2)n . To find a particular solution of the
inhomogeneous problem we try an exponential function qn = D2n with a constant D to
be determined. Plugging into the equation we find
2D2n − D2n−1 = 2n
More interest rate: A bank account gives an interest rate of 5% compounded monthly.
If you invest invest initially $1000, and add $10 every month. How much money do you
have after 10 years? Since the interest is paid monthly we set
3
For the particular solution we try qn = d and find
241
d= d + 10
240
i.e., d = −2400. The general solution is then
n
241
qn = C − 2400
240
and q0 = 1000 gives n
241
qn = 3400 − 2400
240
and so q6 0 = 1963.41
It is easy to see that we are given both q0 and q1 we can determine q2 , q3 , and so on.
Linearity Principle: It is easy to verify that if q̃n and q̂n are two solutions of the second
order homogeneous equation. Then C1 q̃n +C2 q̂n is also a solution for any constant C1 , C2 .
To find the general solution we get inspired by the homogeneous first order equation and
look for solutions of the form
q n = xn
If we plug this into the equation we find
aαn + bαn−1 + cαn−2
and dividing by αn−2 give
ax2 + bx + c = 0
We find (in general) two roots x1 and x2 and the general solution has the form
qn = C1 xn1 + C2 xn2
Example: Solve the second order equation 3qn + 5qn−1 − 2qn−2 = 0, with q0 = 2 and
q1 = −3. If we try qn = xn we obtain the quadratic equation
3x2 + 5x − 2 = 0 or x = 1/3, −2
4
and so the general solution is
n
1
qn = C 1 + C2 (−2)n
3
The initial conditions give 2 = C1 + C2 and −3 = C1 (1/3) + C2 (−2). This gives C1 = 3/7
and C2 = 11/7 and so n
3 1 11
qn = + (−2)n
7 3 7
where qn is unknown and dn is a fixed sequence. As for first order equations we can solve
such equations by
3. Write the general solution as the sum of the particular inhomogeneous equation plus
the general solution of the homogeneous equation.
Application: Random walk and Gambler’s ruin. Consider the set of integers N =
{0, 1, 2, 3, 4, · · · }. Imagine a walker moving along a line, every unit of time he makes a
step and each step he makes is exactly one unit so that his position at any time is some
integer. The rule for the motion of the walker starting at n are
with
p+q+r =1
Instead a walker on a line you can think of a gambler at a casino making bets of $1
at certain game (say red on roulette). He start with a fortune of $n. With probability p
he doubles his bet, that he increase his fortune by $1, with probability q he looses and
5
his fortune decreases by $1, and with probability r he gets his bet back and his fortune
is unchanged.
As we have seen in previous lectures, in many such games the odds of winning are very
close to 1 with p typically around .51. Using our second order difference equations we will
show that even though the odds are only very slightly in favor of the casino, this enough
to ensure that in the long run, the casino will makes lots of money and the gambler not so
much. We also investigate what is the better strategy for a gambler, play small amounts
of money (be cautious) or play big amounts of money (be bold). We shall see that being
bold is the better strategy if odds are not in your favor (i.e. in casino), while if the odds
are in your favor the better strategy is to play small amounts of money.
In order to make the previous problem more precise we imagine the following situation.
• You starting fortune if $j.
• In every game you bet $1.
• Your decide to play until you either loose it all (i.e., your fortune is 0) or you fortune
reaches $N and you then quit.
• What is the probability to win?
We denote by Aj the event that you win starting with $j.
qj = P (Aj ) = Probability to win starting with j
= Probability to reach N before reaching 0 starting from j (3)
To compute qj we use the formula for conditional probability and condition on what
happens at the first game, win, lose, or tie. For every game we have
P (win) = p, P (lose) = q, , P (tie) = r
We have
qj = P (Aj )
= P (Aj |win)P (win) + P (Aj |lose)P (lose) + P (Aj |tie)P (tie)
= qj+1 × p + qj × q + qj−1 × r (4)
since if we win the first game, our fortune is then j + 1, and the the probability that we
then win is simply qj+1 , and son on....
Using that p + q + r = 1 we can rewrite this as the second order equation
pqj+1 − (p + q)qj + qqj−1 = 0
With qj = xj we find the quadratic equation
px2 − (p + q)x + q = 0
6
with solutions
p p p
−p ± (p + q)2 − 4pq −p ± p2 + q 2 − 2pq −p ± (p − q)2 1
x = = = =
2p 2p 2p q/p
and so the general solution is given by
n
n q
qn = C 1 1 + C 2
p
To determine the constants C1 and C2 we use that
q0 = 0 , and qN = 1 .
which follow from the definition of qj as the probability to win (i.e. reaching a fortune of
N ) starting with a fortune of j. We find
N
q
0 = C1 + C2 , 1 = C1 + C2
p
which gives
N !−1
q
C1 = −C2 = 1− ,
p
and so we find
1 − (q/p)n
Gambler0 s ruin probabilities qn =
1 − (q/p)N
Bold or cautious? Using the formula for the gambler’s ruin we can investigate whether
there is a better gambling strategy than betting $1 repeatedly. For example if we start
with $10 and our goal is to reach $100 we choose between
7
1
0.75
0.5
0.25
0 8 16 24 32 40 48 56 64 72 80 88 96
• Play in $1 bets?
• Play in $10 bets?
We find
1 − (51/49)10
Probability to win $100 in $1 bets starting with $10 is q10 = = 0.0091
1 − (51/49)100
while for the other case we use the same formula with N = 10 and j = 1 since we need
to make a net total of 9 wins
1 − (51/49)
Probability to win $100 in $10 bets starting with $10 is q11 = = 0.0829
1 − (51/49)10
that is your chance to win is about 8 in hundred, about nine time better than by playing
in $1 increments. Based on such arguments it seems clear the best strategy is to be bold
if the odds of the game are not in your favor.
If on the contrary the odds are in your favor, even so slightly, say q=.49, and p=.51
then the opposite is true: you should play cautiously. For example with these probabilities
and in the same situation as before, starting with $ 10 and with a $100 goal we find
1 − (49/51)10
Probability to win $100 in $1 bets starting with $10 is q10 = = 0.3358
1 − (49/51)100
while for the other case we use the same formula with N = 10 and j = 1 since we need
to make a net total of 9 wins
1 − (49/51)
Probability to win $100 in $10 bets starting with $10 is q11 = = 0.1189.
1 − (49/51)10
8
In summary we have
If the odds are in your favor be cautious but if the odds are against you be bold!
1. 2qn − 5qn−1 = 0, q0 = 2
2. 2qn − 5qn−1 = 3, q0 = 3
Exercise 2: Your retirement account has a fixed rate of 8% per year paid yearly. You
start saving for retirement at age 30 with a target retirement age of 65 and $0 in your
saving account. Set-up and solve a suitable first order difference equations to answer the
following questions.
1. Suppose you set aside $500 every month. How much money will you have for your
retirement?
2. You want to retire with $500’000. How much should you save every month?
3. Assuming that your salary is going to increase 5 % per year during your life you also
decide you contribution will increase by 5% every year. If your starting contribution
is $500 every month how much money will you have saved at retirement age?
4. Assuming again that your contribution is increasing by 5% every year, what should
your starting contribution be if if you want to reach $500’000 by retirement age?
Exercise 3: Your mortgage is a 30 year fixed rate mortgage at an (fixed) annual rate of
4% compounded monthly.
1. If you borrow $150’000 today, what is the total amount of money will you pay back
to the bank during the next 30 years?
9
2. You decide that you can make a down-payment of $15000 and that $1250 is the
maximal monthly payment you are willing to commit to. How much house can you
buy?
Exercise 4: At a certain casino game if you bet $x you will loose your $x with probability
.505 (so your fortune will idecrease by x) and win $2x with probability $.495 (so your
fortune will increase by x). You walk into the casino with $25 dollars with the goal to get
$200. Compute the probability for you to succeed if you use the following strategies
1. You make repeated $5 bets until you either win $200 or you are wiped out.
2. You make repeated $25 bets until you either win $200 or you are wiped out.
3. You keep betting all your available money, i.e., first bet $25 then bet $50 if you win
the first bet, and so on.
Exercise 5: The following game is proposed to you. You have to perform a random
walk on the integer between 0 and N where you go one step left or one step right with
probability 1/2. But there is a twist: each time you make a step there is a probability 1/10
that you win the game immediately. You win this game if either you win immediately at
some step or if you reach N first. You loose if you reach 0 first.
1. Argue that the probability to win starting at j satisfies the second order equation
1
qj = + .45qj+1 + .45qj−1 , q0 = 0, qN = 1
10
Exercise 6: Martingale strategy. At a certain casino game if you bet $x you will loose
your $x with probability q and win $2x with probability p.
Your great aunt just left you with an inheritance of 2560000 (that is 28 times thousand
dollars) and you decided to move to Las Vegas. Being a gambler, a slacker, and a nerd
you decide to use the following strategy to stay in Vegas for as long as possible.
• At the beginning of each month you go to the casino and bet $10000. If you win
you made a profit of $10’000, you quit and live for a month on your $10000 gain
until you return next month.
10
• If you loose your first bet, you double your bet and stake $20000. If you win this
second bet, you made a profit of $10’000 (why?) and again you quit and live for a
month on your $10000 gain.
• If you loose your first two bets, then you double your bet to $40’000, etc....
2. Find the probability that you go bankrupt in any single given month. What if
p = 1/2?
3. Find the probability that you go bankrupt exactly in your nth visit to the casino?
What if p = 1/2?
4. Find the expected number of times you visit the casino until you go bankrupt. What
if p = 1/2?
Hint: To compute ∞ n−1
compute first ∞ n
P P
n=1 nx n=0 x and then differentiate with
respect to x.
5. Find the expected return on your investment, that is compute the expected amount
of money you made in casino. What if p = 1/2?
11