一
基于均值生成函数时间序列预测算法程序
1.
predict_fun.m
为主程序
;
2.
timeseries.m
和
seriesexpan.m
为调用的子程序
function
ima_pre=predict_fun(b,step)
%
main
program
invokes
timeseries.m
and
seriesexpan.m
%
input
parameters:
%
b-------the
training
data
(vector);
%
step----number
of
prediction
data;
%
output
parameters:
%
ima_pre---the
prediction
data(vector);
old_b=b;
mean_b=sum(old_b)/length(old_b);
std_b=std(old_b);
old_b=(old_b-mean_b)/std_b;
[f,x]=timeseries(old_b);
old_f2=seriesexpan(old_b,step);
%
f(f<0.0001&f>-0.0001)=f(f<0.0001&f>-0.0001)+eps;
R=corrcoef(f);
[eigvector
eigroot]=eig(R);
eigroot=diag(eigroot);
a=eigroot(end:-1:1);
vector=eigvector(:,end:-1:1);
Devote=a./sum(a);
Devotem=cumsum(Devote);
m=find(Devotem>=0.995);
m=m(1);
V1=f*eigvector';
V=V1(:,1:m);
%
old_b=old_b;
old_fai=inv(V'*V)*V'*old_b;
eigvector=eigvector(1:m,1:m);
fai=eigvector*old_fai;
f2=old_f2(:,1:m);
predictvalue=f2*fai;
ima_pre=std_b*predictvalue+mean_b;
1.
子函数
:
timeseries.m
%
timeseries
program%
%
this
program
is
used
to
generate
mean
value
matrix
f;
function
[f,x]=timeseries(data)
%
data--------the
input
sequence
(vector);