Reputation: 51
I'm simulating a Brownian motion in MATLAB, however I'm getting a strange outcome where the variance of the increments of the Brownian motion grow over time when it should stay constant. For example I construct a Brownian motion system,
brown_drift = @(t,X) 0;
brown_vol = @(t,X) .2;
brown_sys = bm(brown_drift, brown_vol);
And then I interpolate 1000 trials with timestep 1 and length 10
inter_brown = interpolate(brown_sys, 0:1:10, zeros(1,1,1000),'Times',[0]);
inter_brown = squeeze(inter_brown);
The increments of a Brownian motion should be independent so if I construct a matrix of the increments and take the variance, they should all be the same and equal to the volatility parameter squared.
inc = inter_brown(2:end,:)-inter_brown(1:end-1,:);
var(inc')
ans = 0.0374 0.1184 0.2071 0.2736 0.3516 0.4190 0.5511 0.5891 0.6767 0.7647
However it clearly doesn't satisfy what comes out of the simple theory where the variance should be 0.2^2 for each increment. It looks like each increment in the future adds 2*0.2^2 to the variance of the increment before it. I can't seem to figure out why this is happening when the Brownian motion seems to satisfy the other theory, e.g. the variance of the motion at a given time. Is there something obvious I'm missing here?
Upvotes: 0
Views: 547
Reputation: 1685
There are three things I would do differently:
1) Choose your timestep of your Brownian paths smaller. The more steps in one path you simulate the more accurate the calculated variance of your increments in each path will be (check with var(var(inc))
). This means for each path you will get more similar results for the variance of the increments.
2) Also the variance of the increments is scaling differently if your time is bigger than 1 (see Volatility over time) so you would get different results depending on your initial time scale. i.e
interpolate(brown_sys, 0:0.1:10, zeros(1,1,1000),'Times',[0]);
would result in a variance of about 0.4
and
interpolate(brown_sys, 0:0.1:100, zeros(1,1,1000),'Times',[0]);
would result in a variance of 4. So just change the time to:
interpolate(brown_sys, 0:dt:1, zeros(1,1,1000),'Times',[0]);
Where you should choose dt
very small i.e. dt = 0.001
;
3) You should consider the variance of inc
and not the transposed one. Because the matrix inter_brown
you obtain has on each column a simulated path. So the steps belonging to one path should be in one column. Thus the matrix inc
you calculate contains the increments according to one path in a column. The var()
of matrices calculates the variance of a sample stored in one column. So if you want to know the variance of the increments of you first path you would have to call something like: var(inc(:,1))
. Calling var(inc)
gives you the variance for each path. You can plot them with plot(var(inc))
. You will then see that the variance of increments is around 0.04
as expected. Check it with mean(var(inc))
.
Upvotes: 1