Estimate the parameters of a Geometric Brownian Motion (through the method of moments) on the data and graphically show the mean and two confidence intervals
[mu,sigma]=gbm(data,dt)
If the variable x follows a Geometric Brownian Motion then it solves the stochastic differential equaiton
dx/x = mu dt + sigma dW
where dW is the differential form of a Wiener process and both "mu" and "sigma" are constant parameters. On historical data, the function estimates both mu and sigma and show a graph with the mean of the process, the mean+/- the standard deviation, and the mean +/-2 times the standard deviation
First we generate 1000 log-normally distributed daily prices for an asset whose initial values is 25 euros. First step is the creation of 1000 normal random variables (with mean 0.1/250 and standard deviation 0.2/sqrt(250))
-->M=grand(1000,1,'nor',0.1/250,0.2/sqrt(250));
Then we create the prices
-->prices=exp(cumsum(M,1))*25;
and apply the function with
-->[mu,sigma]=gbm(prices,1/250);
sigma = 0.2039105
mu = 0.1443338
We see the mean and the standard deviation are close to that we started from. The figure shows the original data, the mean and the confidence intervals.
Francesco Menoncin - Brescia University - 2010