My first question is : How can I count the number of recent calls to a procedure (not exprofile) ?
X := proc ()
Sample(RandomVariable(Normal(0, 1)), 1)
X(); X() ;
should return 2
My second question is:
I have a procedure as seen below which I plot in a component plot Do(%Plot0=X(%Slider_mu,%Slider_sigma,%Slider_t));
The Do call has 3 sliders inputs in the form of mu, sigma, tt.
How can I make sure that the randomvariable r is only updated when I slide mu, sigma and not when I slide tt ?
( I guess r should only be updated if mu and sigma have different values compared to the last call maybe something with
GetProperty('Slider1', 'value'); hummm )
n := 10:
X := proc (mu, sigma, tt) local `Δt`, r, s, t, ss;
`Δt` := evalf(1/tt, 3);
r := Sample(RandomVariable(Normal(mu*`Δt`, sigma*sqrt(`Δt`))), n*tt);
for t to n*tt do s := 500; s[t] := s[t-1]+s[t-1]*r[t] end do;
ss := `<,>`(seq(s[i], i = 0 .. n*tt)); LineChart(ss, color = black, thickness = 2, labels = ["Time", "Stock Price"], labelfont = [Times, Roman, 14], font = [times, roman, 14], tickmarks = [[seq(i = evalf((i-1)/tt, 3), i = 1 .. n*tt+1, tt)], default])
end proc :