Brownian Path Simulation - Plotting more than one path
15 views (last 30 days)
Show older comments
I am to create a discrete sample Brownian path. I believe I have the code complete, but if any mistakes, please do not hesitate in letting me know. I am trying to figure out how to generate 100, 1000, 10000 paths with T = 1 and n = 200. I'm not sure where exactly that goes. Thank you.
function [W] = brownianPath (T,n)
%t = 0, T/n, 2T/n, ..., T where T = termination time & n = steps%
stepsize = T/n;
t = 0:stepsize:T;
dW = zeros(1,n);
W = zeros(1,n);
dW(1) = randn/sqrt(stepsize);
W(1) = dW(1); %W(0) = 0 with probability 1%
for m = 2:n
dW(m) = randn/sqrt(stepsize);
W(m) = W(m-1) + dW(m);
end
plot([0:stepsize:T],[0 W], 'g-');
xlabel('t')
ylabel('W(t)')
end
0 Comments
Answers (1)
See Also
Categories
Find more on Surfaces, Volumes, and Polygons in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!