MATLAB Simple - 线性预测编码和能量预测

MATLAB Simple - Linear Predictive Coding and Energy Forecasting

我有一个数据集,其中包含 274 个样本(9 个月)的住宅家庭日常能源消耗量 (Watts.hour)。 我不确定我是否正确地应用了 lpc 函数。

我的代码如下:

  filename='9-months.csv';
  energy = csvread(filename);


  C=zeros(5,1);
  counter=0;


  N=3;



  for n=274:-1:31

  w2=energy(1:n-1,1);
  a=lpc(w2,N);

  energy_estimated=0; 

      for X = 1:N
      energy_estimated = energy_estimated + (-a(X+1)*energy(n-X));
      end

  w_real=energy(n);
  error2=abs(w_real-energy_estimated);


  counter=counter+1;

  C(counter,1)=error2;
  end

  mean_error=round(mean(C));

作为"n"分析的样本,我将使用能量数组的值,从 1 到 n-1,来计算 lpc 系数(N=3)。

之后,它会将计算出的系数应用到显示的"for"周期,以计算估计能量。

最后error2输出真实能量与估计值的误差

在提供的示例 (http://www.mathworks.com/help/signal/ref/lpc.html) 中使用了一些过滤器。我需要对其应用任何过滤器吗?我的方法正确吗?

非常感谢您!

lpc 似乎使用正确,但您的代码还有一些其他问题。我在他 "for n" :

的地址
for n=31:274 %for me it would seem more logically to go forward in time

  w2=energy(1:n-1,1);
  a=lpc(w2,N);


  energy_estimate=filter([0 -a(2:end)],1,w2);
  energy_estimate=energy_estimate(end);

  estimates(n)=energy_estimate;


end

error=energy(31:274)-estimates(31:274)';
meanerror=mean(error); %you dont really round mean errors

filter 正是您要对 X=1:N 循环执行的操作。但这将对整个 w2 向量执行计算。如果你只想要最后一个值,也可以使用 (end) 命令。

现在没有理由计算每个值的误差,然后将它们添加到一个向量中,您可以在计算后更快地执行此操作。

现在,如果您尝试使用 lpc 估算未来值,它可能会那样工作,但您暗示每个值仅取决于最后 3 个值。您是否尝试过多项式方法?我认为这会更接近现实。