Last data update: 2014.03.03

R: Brownian motion, Brownian bridge, geometric Brownian motion,...
BMR Documentation

Brownian motion, Brownian bridge, geometric Brownian motion, and arithmetic Brownian motion simulators

Description

The (S3) generic function for simulation of brownian motion, brownian bridge, geometric brownian motion, and arithmetic brownian motion.

Usage

BM(N, ...)
BB(N, ...)
GBM(N, ...)
ABM(N, ...)

## Default S3 method:
BM(N =100,M=1,x0=0,t0=0,T=1,Dt, ...)
## Default S3 method:
BB(N =100,M=1,x0=0,y=1,t0=0,T=1,Dt, ...)
## Default S3 method:
GBM(N =100,M=1,x0=1,t0=0,T=1,Dt,theta=1,sigma=1, ...)
## Default S3 method:
ABM(N =100,M=1,x0=0,t0=0,T=1,Dt,theta=1,sigma=1, ...)

Arguments

N

number of simulation steps.

M

number of trajectories.

x0

initial value of the process at time code{t0}.

y

terminal value of the process at time code{T} of the BB.

t0

initial time.

T

final time.

Dt

time step of the simulation (discretization). If it is missing a default Dt = (T-t0)/N.

theta

the interest rate of the ABM and GBM.

sigma

the volatility of the ABM and GBM.

...

further arguments for (non-default) methods.

Details

The function BM returns a trajectory of the standard Brownian motion (Wiener process) in the time interval [t0,T]. Indeed, for W(dt) it holds true that W(dt) = W(dt) - W(0) -> N(0,dt) -> sqrt(dt) * N(0,1), where N(0,1) is normal distribution Normal.

The function BB returns a trajectory of the Brownian bridge starting at x0 at time t0 and ending at y at time T; i.e., the diffusion process solution of stochastic differential equation:

dX(t) = ((y-X(t))/(T-t)) dt + dW(t)

The function GBM returns a trajectory of the geometric Brownian motion starting at x0 at time t0; i.e., the diffusion process solution of stochastic differential equation:

dX(t) = theta X(t) dt + sigma X(t) dW(t)

The function ABM returns a trajectory of the arithmetic Brownian motion starting at x0 at time t0; i.e.,; the diffusion process solution of stochastic differential equation:

dX(t) = theta dt + sigma dW(t)

Value

X

an visible ts object.

Author(s)

A.C. Guidoum, K. Boukhetala.

References

Allen, E. (2007). Modeling with Ito stochastic differential equations. Springer-Verlag, New York.

Jedrzejewski, F. (2009). Modeles aleatoires et physique probabiliste. Springer-Verlag, New York.

Henderson, D and Plaschko, P. (2006). Stochastic differential equations in science and engineering. World Scientific.

See Also

This functions BM, BBridge and GBM are available in other packages such as sde.

Examples


op <- par(mfrow = c(2, 2))

## Brownian motion
set.seed(1234)
X <- BM(N = 1000, M = 50)
plot(X,plot.type="single")
lines(as.vector(time(X)),rowMeans(X),col="red")

## Brownian bridge
set.seed(1234)
X <- BB(N = 1000, M =50)
plot(X,plot.type="single")
lines(as.vector(time(X)),rowMeans(X),col="red")

## Geometric Brownian motion
set.seed(1234)
X <- GBM(N = 1000, M = 50)
plot(X,plot.type="single")
lines(as.vector(time(X)),rowMeans(X),col="red")

## Arithmetic Brownian motion
set.seed(1234)
X <- ABM(N = 1000, M = 50)
plot(X,plot.type="single")
lines(as.vector(time(X)),rowMeans(X),col="red")

par(op)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(Sim.DiffProc)
Package 'Sim.DiffProc' version 3.2 loaded.
help(Sim.DiffProc) for summary information.
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Sim.DiffProc/ABM.Rd_%03d_medium.png", width=480, height=480)
> ### Name: BM
> ### Title: Brownian motion, Brownian bridge, geometric Brownian motion, and
> ###   arithmetic Brownian motion simulators
> ### Aliases: ABM BB BM GBM ABM.default BB.default BM.default GBM.default
> ### Keywords: BM sde ts
> 
> ### ** Examples
> 
> 
> op <- par(mfrow = c(2, 2))
> 
> ## Brownian motion
> set.seed(1234)
> X <- BM(N = 1000, M = 50)
> plot(X,plot.type="single")
> lines(as.vector(time(X)),rowMeans(X),col="red")
> 
> ## Brownian bridge
> set.seed(1234)
> X <- BB(N = 1000, M =50)
> plot(X,plot.type="single")
> lines(as.vector(time(X)),rowMeans(X),col="red")
> 
> ## Geometric Brownian motion
> set.seed(1234)
> X <- GBM(N = 1000, M = 50)
> plot(X,plot.type="single")
> lines(as.vector(time(X)),rowMeans(X),col="red")
> 
> ## Arithmetic Brownian motion
> set.seed(1234)
> X <- ABM(N = 1000, M = 50)
> plot(X,plot.type="single")
> lines(as.vector(time(X)),rowMeans(X),col="red")
> 
> par(op)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>