gbm: Generate a time series of geometric Brownian motion.

Description Usage Arguments Examples

Description

This function generatea a time series of one dimension geometric Brownian motion. adapted from http://cos.name/wp-content/uploads/2008/12/stochastic-differential-equation-with-r.pdf .

Usage

1
  gbm(x0 = 1, mu = 0, sigma = 1, t0 = 0, t = 1, n = 100)

Arguments

x0

the start value, with the default value 1

mu

the interest rate, with the default value 0

sigma

the diffusion coefficient, with the default value 1

t0

the start time point, with the default value 0

t

the end time point, with the default value 1

n

the number of points between t0 and t that will be generated, with the default value 100

Examples

1
2
3
4
gbm()
plot(gbm())
b <- gbm(x0=1, mu=1, sigma=0.5, t0=1, t=2, n=1000)
plot(b)

Example output

Time Series:
Start = c(0, 1) 
End = c(1, 1) 
Frequency = 100 
  [1] 1.0000000 0.9283979 0.7913013 0.7583055 0.8239793 0.7677991 0.8875404
  [8] 0.9237635 0.8792578 0.9621269 1.0291470 0.9822871 1.0038674 0.9094896
 [15] 0.9773605 0.9724354 1.0101490 0.9804242 1.0789840 1.1009286 1.2267287
 [22] 1.1039732 1.1204137 0.9864070 1.0705425 0.8868755 0.9137741 1.0040882
 [29] 1.0272637 0.9733764 0.8887273 0.8219372 0.8185850 0.9154225 0.9031649
 [36] 0.8454445 0.7769974 0.8017499 0.7132327 0.6463514 0.6767176 0.6959048
 [43] 0.6413451 0.7885220 0.7117696 0.7746343 0.8080761 0.8186992 0.9185352
 [50] 0.8570541 1.0045619 1.0676986 0.9890260 0.8670116 0.9168347 0.9018657
 [57] 1.0144935 0.8978283 0.8243624 0.7450672 0.6465305 0.6970487 0.6772660
 [64] 0.7416839 0.6539919 0.6504514 0.7926131 0.7672355 0.6779190 0.7721787
 [71] 0.7823312 0.8067696 0.8615388 0.8380834 0.8624921 0.9143343 0.9903763
 [78] 1.0925728 1.0706419 1.0680013 0.9628066 0.7989887 0.8116490 0.8082534
 [85] 0.8187242 0.8633256 0.8956454 0.8482265 0.7971930 1.0343852 1.0990856
 [92] 1.0867972 0.9931184 0.9055143 1.0629747 1.1265435 1.1968676 1.2628286
 [99] 1.4421253 1.2857514 1.2762598

somebm documentation built on May 2, 2019, 9:30 a.m.