📄 smothdemo.m
字号:
function smothdemo
% 指数平滑预测
% Parameter:
alpha = 0.8;
nseq = [105851 107507 109300 111026 112704 114333 115823 117171 118517 ...
119850 121121 122389 123626 124761 125786 126743 127627 128453 129227 129988 130756 131448 132129];
% Base the Input Predict Method to solve the nseq
yfilter(1) = nseq(1);
for i=2:length(nseq)
yfilter(i) = alpha*nseq(i) + (1-alpha)*yfilter(i-1);
end
% Plot the orignal Graphic
x = 1:1:8; % 33个标本数据
y = nseq(16:23);
plot(x,y, '--bs',x,yfilter(16:23), '--rs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',2);
mse = MSE(nseq(16:23), yfilter(16:23));
avmae = mae(nseq(16:23), yfilter(16:23));
rerr = releaterror(nseq(16:23), yfilter(16:23));
disp( sprintf('The avarage real error is: %f', avmae ));
disp( sprintf('The mean square error is: %f', mse ));
disp( sprintf('平均相对误差 is %f', rerr));
title('全社会客货运输量指数平滑预测', 'FontSize', 10);
xlabel('月份', 'FontSize', 10);
ylabel('铁路客户量(亿)', 'FontSize', 10);
grid on
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -