0
$\begingroup$

I have the following code it runs the model one time with 6000 iterations:

SeedRandom[1]
cf = Compile[{{noise, _Real,1}, {F, _Real},{b, _Real},
       {c, _Real}, {α0, _Real}, {αn, _Real}, {αp, _Real}, 
       {β, _Real}, {μ, _Real}, {WF1, _Real}, {WC1, _Real}}, 
  Block[{P, ED, DC, DF, WF, WC, a, n},
   n = Length[noise];
   P = Table[0., {n}];
   ED = Table[0., {n}];
   DC = Table[0., {n}];
   DF = Table[0., {n}];
   WF = Table[0., {n}];
   WC = Table[0., {n}];
   a = Table[0., {n}];
   P[[1 ;; 3]] = {F, F, F + 0.01};
   WF[[1]] = WF1;
   WC[[1]] = WC1;
   Do[P[[i]] = P[[i - 1]] + μ ED[[i - 1]] + noise[[i]];
    DC[[i]] = b (P[[i]] - P[[i - 1]]);
    DF[[i]] = c (F - P[[i]]);
    a[[i]] = α0 + αn (WF[[i - 1]] - 
         WC[[i - 1]]) + αp (P[[i - 1]] - F)^2;
    WF[[i]] = 1./(1. + Exp[-β a[[i]]]);
    WC[[i]] = 1. - WF[[i]];
    ED[[i]] = WC[[i]] DC[[i]] + WF[[i]] DF[[i]];, {i, 2, n}];
   {P, DC, DF, a, WF, WC, ED}], CompilationTarget -> "WVM", 
  RuntimeAttributes -> {Listable}, Parallelization -> True, 
  RuntimeOptions -> "Speed"]

n = 6000;
m = 1;
μ = 0.01;
β = 1;
b = 0.01;
c = 0.01;
α0 = 0;
αn = -0.4;
αp = 10;
F = 1.;
WF1 = 0.2;
WC1 = 0.8;
noise = RandomVariate[NormalDistribution[0, 0.03], {m, n}];

data = cf[noise, F, b, c, α0, αn, αp, β, μ, WF1, WC1];

The values for P are accessed via data[[All,1,All]]

I want to evaluate the differences in P, WF, WC and a when I change the value one or more of the alphas. The problem I'm facing is that when I change the value of one or more of the alphas the values for P aren't changing despite the values of a, WF and WCchanging. I tried using BlockRandom before the Table commands but that didn't seem to do anything. So my question is why do the values of P not change while changing variables that influence P? Thanks for your help in advance.

$\endgroup$
  • 2
    $\begingroup$ Can you at all minimize this to more succinctly describe the actual problem? There seems to be a lot of extra "fluff" here. $\endgroup$ – user6014 Jan 18 '18 at 15:01
  • $\begingroup$ in addition to trimming it down you need to provide values for m,n,F,b,... $\endgroup$ – george2079 Jan 18 '18 at 21:40
  • $\begingroup$ Trimmed it down and provided the values $\endgroup$ – user52902 Jan 19 '18 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy