I have the following code:
Brownian[x0_,μ_, σ_, t_, h_] :=
Module[{d = Sqrt[h], m = t/h},
g = Table[Random[NormalDistribution[0, d]], {m}];
sums = FoldList[Plus, 0, g]; Table[X[i] = sums[[i + 1]], {i, 0, m}];
geometric = Table[x0*E^((μ - σ^2/2)*i*h + σ*X[i]), {i, 0, m}]]
Brownian[78.55, 0.3693, 0.16689, .5, 0.001];
Xt = geometric; m = 500; h = .001;
g1 = Table[{i*h, Xt[[i + 1]]}, {i, 0, m}];
This code works well, and it generates a g1 table as desired. However, I wish to loop this and generate many "g" tables (g1,g2,g3, etc.) all with different contents as there are random variables involved in my code. My desire is to be able to hit g1 and enter, and see contents in that table, then g2 and enter and see different contents. The reason why I want to do this is because I need to generate say 50 samples, and I would like to not want to hit enter every time.
I have tried a Do[ ...code...,{k,50}] and added a subscript k under "g" where there is a random function for the normal distribution, under sums, geometric, brownian, Xt, and g1 in hopes that I could hit like a g1(sub1) or a g1(sub2) and get different tables, yet I get errors and red bars. Anyone care to help me out?
g1
,g2
ecc., or would be having it in a list of tables callable withg[[1]]
,g[[2]]
... be enough? $\endgroup$gi
defined? Identical tog1
? If you want for exampleg2 = Table[{i*h, Xt[[i + 2]]}, {i, 0, m}]
you would have a problem sinceXt
only has 501 elements $\endgroup$GeometricBrownianMotionProcess
) to generate your random data? $\endgroup$