The following is a simple example of a much larger simulation that I want to run
Define some processes
norTheta[mu_, sigma_] := Random[NormalDistribution[mu, sigma]];
norPi[mu_, sigma_] := Random[NormalDistribution[mu, sigma]];
thetaNext[thetaNow_] :=
thetaNow + (-lambdaTheta*(thetaNow - thetaBar)*deltaT +
sigmaTheta*norTheta[0, 1]*Sqrt[deltaT]);
piNext[piNow_, thetaNow_] :=
piNow + (-lambdaPi*(piNow - thetaNow)*deltaT +
sigmaPi*norPi[0, 1]*Sqrt[deltaT]);
Then define some parameters
lambdaTheta = 0.07;
thetaBar = 0.02;
sigmaTheta = 0.012;
lambdaPi = 1.0;
sigmaPi = 0.0125;
Then simulate the system
steps = 252;
T = 50;
deltaT = 1/steps; // N
Maturity = T*steps;
process = Transpose[NestList[{ piNext[#[[1]], #[[2]]],
thetaNext[#[[2]]]} &,{0.02, 0.02}, Maturity]];
I have two questions: (1) what is the best MMA of repeating the above 10,000 at each loop saving the output 'process' for use later; (2) what is the fastest way of doing this?
Many thanks, Paul
DoandCompile? or did I misunderstand the question? – acl Oct 29 '12 at 11:18Table? – Sjoerd C. de Vries Oct 29 '12 at 12:36Put[]... – J. M.'s missing motivation Oct 29 '12 at 12:59Table. I even linked to its reference page. Don't know where in my answer I suggested to useReap/Sow. The table itself could be saved withDumpSave. See also http://mathematica.stackexchange.com/a/2008/57 and http://mathematica.stackexchange.com/a/209/57 – Sjoerd C. de Vries Oct 29 '12 at 14:11