0% found this document useful (0 votes)
147 views2 pages

Brownian Motion in R

1. This document provides instructions for simulating geometric Brownian motion by modifying an existing random walk generator to simulate Brownian motion with drift. 2. It describes downloading and testing an existing random walk generator code, then modifying it to simulate standard Brownian motion by setting the probability to 0.5 and diffusion coefficient to 1/2. 3. Instructions are given to further modify the code to simulate Brownian motion with drift by multiplying the standard Brownian motion by the drift parameter and variance, and adding the drift term. 4. The final step is to modify the code to take an initial value parameter and plot the geometric Brownian motion process by exponentiating the Brownian motion with drift at each time step

Uploaded by

Marco R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
147 views2 pages

Brownian Motion in R

1. This document provides instructions for simulating geometric Brownian motion by modifying an existing random walk generator to simulate Brownian motion with drift. 2. It describes downloading and testing an existing random walk generator code, then modifying it to simulate standard Brownian motion by setting the probability to 0.5 and diffusion coefficient to 1/2. 3. Instructions are given to further modify the code to simulate Brownian motion with drift by multiplying the standard Brownian motion by the drift parameter and variance, and adding the drift term. 4. The final step is to modify the code to take an initial value parameter and plot the geometric Brownian motion process by exponentiating the Brownian motion with drift at each time step

Uploaded by

Marco R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Project Part 2 — Brownian Motion with Drift, Geometric Brownian Motion

0. This is an optional project for extra credit only. Your grade will not be affected if you decline to
do it. Steps 1-4 are preparatory. Step 5 describes the finished product. This part of the project
should be submitted as a Canvas assignment by 11:59 pm on Wednesday, November 25.
1. Introduction: Brownian motion with drift parameter µ and variance parameter σ 2 is the process

Xt = µt + σBt ,

where Bt is standard Brownian motion. And geometric Brownian motion is

Gt = G0 eXt ,

where G0 > 0. For this super-double-bonus-extra-credit part of the project, you will create a
geometric Brownian motion simulator by adapting your random walk generator form the first part
of the project.
2. You may use my random walk generator if you wish. Go to Canvas/Files/R/randomwalk.R and
download. It generates a random walk on [0, T ] with n time steps, spatial increment dx and
probability p of a step to the right. Once you’ve downloaded it and used the R source command
to activate it in your workspace, try typing randomwalk(1,20,.1,.5). You should get a random
walk on [0, 1] with 20 time steps, spatial increment dx = .1, with p = .5 .
3. To approximate standard Brownian motion, we used a symmetric random walk, i.e. a random
walk with p√= .5. So you should fix p at this value. We also set the diffusion coefficient to 1/2, so
that ∆x = ∆t. Hence √ you can get rid dx as a variable. Once you’ve defined dt in the body of
your code, just set dx = dt. With these changes, your random walk generator can be considered
a standard Brownian motion simulator as long as you choose dt = T /n small enough. Try it out
with T = 1 and n = 100. You should get something resembling a Brownian path.
4. It is very easy to modify your code to simulate Brownian motion with drift. It already plots an
approximation to Bt . You have to figure out how to multiply that by σ and add µt. Here is a
sample path on [0, 1], with n = 200 time steps, µ = .1 and σ 2 = .04.

Brownian Motion with drift parameter 0.1


and variance parameter 0.04
0.20
0.15
0.10
0.05
x

0.00
−0.05
−0.10

0.0 0.2 0.4 0.6 0.8 1.0

t
5. Last step: This one should be very easy. Modify your code so that it takes the additonal argument
G0 > 0, and then plots Gt = G0 eXt on an interval [0, T ]. In particular,
a. Give the finished product an appropriate name such as GeoBromo.R.
b. The first line of your code should be something like

GeoBromo ← function(T, n, µ, σ, G0 ){

Once again, you don’t have to call the function “GeoBromo” but it’s certainly a reasonable choice.
Feel free to use m, s and G0 (or any other approriate variable names) instead of µ, σ and G0 .
c. Your code should be (lightly) commented.

d. The command GeoBromo(T,n, µ, σ, G0 ) should produce a plot of G0 eXt on [0, T ] with n time
steps of size dt = T /n, and whatever values of µ, σ and G0 you choose. It should look something
like this:
Geometric Brownian Motion with drift parameter 0.6 ,
variance parameter 0.04 and initial value 2
3.5
3.0
x

2.5
2.0

0.0 0.2 0.4 0.6 0.8 1.0

You might also like