0
我已經rewitten此作爲以下,
NN = 2000;
mu = 0;
sigma = 10;
task3a = Table[Random[NormalDistribution[mu,sigma]], {NN}];
ListPlot[task3a, AxesLabel->{" No.obs.", "value of the obs"},
PlotLabel -> " Normal Distribution"];
a= 0.6;
b =-0.45;
task4a = Table [0, {NN}] ;
task4a[[1]] = task3a[[1]];
task4a[[2]] = a*task4a[[1]] +task3a[[2]];
For [i = 3, i <= NN, i++,
task4a[[i]] = a*task4a[[i -1]]
+ b*task4a[[i -2]]
+ task3a[[i]];
]
ListPlot[task4a, AxesLabel -> {"No.obs.", "value of the obs"}, PlotLabel-> "Autoregression process for norm.dist. white noise"];
(**************************************************)
avg = (1/NN) * Sum[task4a[[i]], {1, NN}];
task5a = Table[0, {33}] ;
For [k = 0, k <= 32, k++,
task5a[[k + 1]] = (1/(NN-k)) *
Sum[(task4a[[i]] -avg)*(task4a[[i + k]] - avg), {1, NN-k}] ;
]
ListPlot[task5a, PlotLabel ->"K estimator for AR(2) normal distribution", Joined -> True, PlotRange ->All, AxesLabel -> {"k", "K(k)"}] ;
錯誤消息
上面的代碼被生成以下錯誤消息Sum::itraw
,
看起來,for循環存在一些問題。
我聽不懂。
在'Sum'迭代應'{I,1,NN-K}' – agentp