My simulated Wiener process (Matlab)

Joined
5/21/09
Messages
13
Points
11
Hi,


I am using Matlab to simulate a pure Wiener process. The initial value is 1, drift is 0, diffusion is 1, 100 timesteps, 1000 paths, from t = 0 to 1. My results is attached with this post.

My graph clearly shows the expected value at T = 1 is 1, so this is good. Theoretical Wiener has variance (1-0=1) at T=1. So the final values should be in [0,2] range, but this is not the case in my graph. Anybody knows why?



x0 = 1;
A = 0;
B = 1;
T = 1;
N = 100
M = 1000;

randn('state', 88); % Initalise the random generator
dt = repmat(T/N, 1, M); % Size of a single time step
x = repmat(x0, N+1, M); % Array to hold the simulation
t = linspace(0, T, N+1); % Array to hold times

for i=1:N
x(i+1,: ) = x(i,: ) + (A * dt) + (B * sqrt(T/N) * randn(1,M));
end

% Draw the distributions

clf reset;
plot(t,x);

Wiener.jpg
 

Attachments

  • Wiener.jpg
    Wiener.jpg
    59.5 KB · Views: 236
Looks very much like an assignment question to me :D. But what do you mean by,

" So the final values should be in [1,2] range, but this is not the case in my graph"??

Why should they be within that range???
 
Yes, this is an assignment question. I wrote the program and tried to verify my results. I thought Brownian Motion have variance T-t, so the values at maturity must be in [1-1,1+1] range.
 
You are simulating from time 0 to time 1, so the variance at time t=1 should be equal to 1 (theoretically). Empirically, the variance across the 1000 sims of your simulated values at time t=1, will not be exactly equal to 1. You will have to play around a bit with the discretisation of the sde (e.g. increase number of time steps) and/ or your number of sims to achieve better approximation to the theoretical variance. Also for the particular example given, your theoretical variance is,

(\int_0^1 E\[\sigma^2 \]ds=1)
 
The variance of a random variable averages the squares of the deviations of its possible values from its mean value.

In your discrete case
( \operatorname{Var}(X)=\frac{1}{M}\sum_{m=1}^{M}(x^m-\mu)^2)
Therefore you recognize that some (x^m) are near the mean value (\mu) and a few of them are far apart from (\mu).
 
For a normal distribution with standard deviation 1, 95% of the data falls within 2 standard deviations of the mean. That is what your graph shows at time T=1.
 
Back
Top Bottom