clear
x0=[89677,99215,109655,120333,135823,159878,182321,209407,246619,300670];
pre_num=10;n=length(x0);
disp(‘级比检验‘)
lambda=x0(1:end-1)./x0(2:end);
range=minmax(lambda)
x1=cumsum(x0);z=0.5*(x1(2:end)+x1(1:end-1));
Y=x0(2:end)‘;
B=[-z(1:end)‘ ones(n-1,1)];
u=B\Y; %u=inv(B‘*B)*B‘*Y
a=u(1)
b=u(2)
x0_pre=[x0(1) ones(1,n+pre_num-1)];
for k=1:n-1+pre_num
x0_pre(k+1)=(x0(1)-b/a)*(exp(-a*k)-exp(-a*(k-1)));
end
err=[x0 - x0_pre(1:n)];
epsilon=abs(err)./x0(1:n).*100
disp(‘预测值‘)
disp(x0_pre)
disp(‘相对误差‘)
disp(epsilon)
t1=1999:2008;
t2=1999:2018;
plot(t1,x0,‘o‘,t2,x0_pre,‘LineWidth‘,2) %原始数据与预测数据的比较
xlabel(‘年份‘)
ylabel(‘利润‘)
时间: 2024-10-13 19:58:17