Monte Carlo Simulation OU-Process

  • Thread starter Thread starter hiddy
  • Start date Start date
Joined
4/17/09
Messages
1
Points
11
Hey
i have a problem in computing a monte carlo simulation of an Ornstein -Uhlenbeck process. Does anybody know how to do it, in matlab or R if possible?
I found a matlab code at sitmo.com:
Code:
function S = OU_Simulate(S0, dT, n, mu, sigma, lambda)

    a = exp(-lambda*dT);
    b = mu*(1-a);
    c = sigma*sqrt((1-a*a)/2/lambda);

    S = [S0 filter(1,[1 -a], b+c*randn(1,n), a*S0)];
end
but that gives me just one rowvector, just one simulation. But I would need a lot more for my simulation. Does anybody can help me, Im really despearte, because I'm not good at writing codes and do need this simulation very badly:cry:

Hope anybody can help me!

regards
rina
 
Without knowing exactly what you want to do, its pretty hard to answer your question. You already appear to have found code to generate a single path, so some simple (although not necessarily the most efficient) solution is to just run that function some number N times for as many simulations as you want... store the output vector S as a row in some bigger matrix M and then do whatever pricing formula or whatever you want to do over that M? Keep in mind that if you only need to use endpoints, then you're better off returning S[end] and storing that than the entire S[~] path... but again, I dont know what it is you're trying to achieve.
 
Back
Top Bottom