Scilab:如何使用“lev”和“filter”来模拟AR1流程?

时间:2018-02-11 07:13:53

标签: model signal-processing scilab

我需要将AR1模型拟合为一系列值。阅读Scilab文档,我想出了下面示例中的方法(使用新代码编辑并获得更完整的结果):

//Testing "filter" and "lev" function for AR1 model y(t) = 0.8*y(t-1) - v016.3
rand("seed", 0);
time = (1:128)';
y = rand(128,1, "normal");  //128 values of gaussian noise
A = [1];    //Coefficients of AR1 polinomial denominator: A(1)+A(2)*y(t-1)
B = [0, 0.8];  //Coefficients of AR1 polinomial numerator: B(1)+B(2)*y(t-1)
z = filter(B,A, y);    //AR1 process from series y
scf(0); clf(0);
 plot(time, y, "+");
 plot(time, z, "-k");
arc = lev(z);    //Calculates AR coefficients vith "lev"
arc = arc(1:2);
z_mod = filter(arc,1, y);   //Modeled series
plot(time, z_mod, "-g");
ar_norm = arc/arc(1);
z_mod2 = filter(ar_norm,1, y);    //Second modeled series from normalized coefficients
plot(time, z_mod2, "-r");
legend("y", "z", "z_mod", "z_mod2");
//End of Code

这些是图形形式的结果。

enter image description here

以数字形式:

  >B
   B  =

   0.    0.8  

-->arc
arc  =

2.51968    
- 5.4210567  

-->ar_norm
ar_norm  =

1.         
- 2.1514862  

我希望用Levinson方法计算的AR系数至少接近我输入的B,但事实并非如此。有人可以帮我解决这个问题吗?

0 个答案:

没有答案