Brownian Path Simulation - Plotting more than one path

15 Ansichten (letzte 30 Tage)
Mel Hernandez
Mel Hernandez am 6 Feb. 2018
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

Antworten (1)

Abhishek Ballaney
Abhishek Ballaney am 7 Feb. 2018
Bearbeitet: Walter Roberson am 11 Feb. 2018

Kategorien

Mehr zu Surfaces, Volumes, and Polygons finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by