Quick Generating Geometric Brownian motion avoiding unnecessary loops using the cumsum function. Technical function implemented in the pricing functions of the package.
Usage
fastGBM(Spot = 1, sigma = 0.2, n = 1000, m = 365, r = 0.06, dr = 0, mT = 1)
Arguments
Spot
Spot price of the underlying asset (e.g. stock).
sigma
Volatility of the underlying asset.
n
Number of paths simulated.
m
Number of time steps in the simulation.
r
Interest rate of the numeraire currency (e.g. EUR).
dr
Dividend rate of the underlying asset.
mT
Maturity time (years).
Value
Table with paths generated (each row is a path, class "matrix")
Author(s)
Mikhail A. Beketov
See Also
Functions: AmerPutLSM,
AmerPutLSM_AV,
AmerPutLSM_CV,
AsianAmerPutLSM,
QuantoAmerPutLSM, and
QuantoAmerPutLSM_AV.
Examples
fastGBM(n=10, m=5)
matplot(t(fastGBM(n=100, m=100)), type="l") # matrix transpose by "t()"
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(LSMonteCarlo)
Loading required package: mvtnorm
Loading required package: fBasics
Loading required package: timeDate
Loading required package: timeSeries
Rmetrics Package fBasics
Analysing Markets and calculating Basic Statistics
Copyright (C) 2005-2014 Rmetrics Association Zurich
Educational Software for Financial Engineering and Computational Science
Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY.
https://www.rmetrics.org --- Mail to: info@rmetrics.org
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/LSMonteCarlo/fastGBM.Rd_%03d_medium.png", width=480, height=480)
> ### Name: fastGBM
> ### Title: Generating Geometric Brownian motion
> ### Aliases: fastGBM
> ### Keywords: Monte Carlo Option pricing American put
>
> ### ** Examples
>
> fastGBM(n=10, m=5)
[,1] [,2] [,3] [,4] [,5]
[1,] 1.0359150 1.0522371 1.0139064 1.0256987 1.1694746
[2,] 1.0130733 0.8942070 0.9457602 1.0972365 1.1035148
[3,] 1.0422711 0.9042632 0.9196957 0.9439036 0.8894174
[4,] 1.0411774 0.9138912 0.8571956 0.8636655 0.8536363
[5,] 1.1501075 1.1997022 1.0851399 1.0312982 1.1727600
[6,] 0.9059159 0.8413841 0.8292239 0.9727707 0.9961941
[7,] 0.8397289 0.7856976 0.8715087 0.8580766 0.9082090
[8,] 0.9256751 1.0669616 1.2642625 1.4478672 1.5047979
[9,] 1.0201057 1.1186824 1.0863598 1.0505711 1.1030214
[10,] 1.0532574 0.9523579 0.9395620 0.9196648 1.0261853
> matplot(t(fastGBM(n=100, m=100)), type="l") # matrix transpose by "t()"
>
>
>
>
>
> dev.off()
null device
1
>