附件:
%原始数列 A
A =
[83529,93853,105930,109381,104372,107077,98738,89455,81649,73484,67759,65225,62387,59
997,58539,58523,58022,63093,63772,53196];
n = length(A);
%对原始数列 A 做累加得到数列 B
B = cumsum(A);
%对数列 B 做紧邻均值生成
for i = 2:n
C(i) = (B(i) + B(i - 1))/2;
end
C(1) = [];
%构造数据矩阵
B = [-C;ones(1,n-1)];
Y = A; Y(1) = []; Y = Y';
%使用最小二乘法计算参数 a(发展系数)和 b(灰作用量)
c = inv(B*B')*B*Y;
c = c';
a = c(1); b = c(2);
%预测后续数据
F = []; F(1) = A(1);
for i = 2:(n+10)
F(i) = (A(1)-b/a)/exp(a*(i-1))+ b/a;
end
%对数列 F 累减还原,得到预测出的数据
G = []; G(1) = A(1);
for i = 2:(n+10)
G(i) = F(i) - F(i-1); %得到预测出来的数据
end
disp('预测数据为:');
G
%模型检验
H = G(1:20);
%计算残差序列
epsilon = A - H;