I am doing some work with black-scholes and am trying to find random interest rates based on some given information. This is my original code:
dt = .0001;
mu = 0;
gamma = .005;
t = .0833;
random = RandomVariate[NormalDistribution[0, dt^.5], 10^2];
Z = Table[0, 10^2 + 1];
Z[[1]] = .0158;
i = 2;
While[i <= 834,
Z[[i]] = Z[[i - 1]] + mu*dt + (gamma)*random[[i - 1]];
i++
];
(*have to make this loop 100 times*)
ListPlot[Z, DataRange -> {0, 100*dt}, PlotRange -> All];
Print[Z];
My main goal is just to get the list of values for interest rates that should be seen as 100X834 in table form. I've received the following revision to my code, from stack exchange, however it isn't outputting the correct table form that I need, I am not sure if I need to put Prepend into my while loop to get it to iterate correctly, or how I can control the dimensions of the table to give me the amount of values I need.
dt = .0001;
mu = 0;
gamma = .005;
t = .0833;
rndm := RandomVariate[NormalDistribution[0, dt^.5], 10^2];
Prepend[Accumulate[rndm] gamma + mu dt + .0158, .0158];
k = 100;
SeedRandom[1]
W = Table[Prepend[Accumulate[rndm] gamma + mu dt + .0158, .0158],
k];
While
loop could also be replaced by aFoldList
call, with your value ofZ[[1]]
as a starting point, andrndm
as the list to be folded in. $\endgroup$10^2
with834
inrndm := RandomVariate[NormalDistribution[0, dt^.5], 10^2];
? $\endgroup$