The below code is quite good but one thing that is annoying is that we get the same trajectory all the time.
Any suggestions on how this can be fixed ? ( when the simulation starts over I would like to have a new trajectory)
I tried to put the random variable inside the procedure but the result was that all trajectories are changing all the time, which
was not really what I wanted .....
restart : with(Statistics) : with(plots) : randomize() :
n := 50 : r := Sample(RandomVariable(Normal(0, 5)), n) :
s := 100 : for i from 2 to n do s[i] := s[i-1]+r[i] end do :
for i to n do p[i] := [seq(s[i], i = 1 .. i)] end do :
An := proc(time) LineChart(p[round(time)], labels = ["Time", "Stock Price"]) end proc :
animate(An, [time], time = 1 .. n, frames = n) ;