資源描述:
《基于均值生成函數(shù)時間序列預(yù)測算法程序》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、基于均值生成函數(shù)時間序列預(yù)測算法程序1.predict_fun.m為主程序;2.timeseries.m和seriesexpan.m為調(diào)用的子程序functionima_pre=predict_fun(b,step)%mainprograminvokestimeseries.mandseriesexpan.m%inputparameters:%b-------thetrainingdata(vector);%step----numberofpredictiondata;%outputparameters:%ima_pre---the
2、predictiondata(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);[eigvectoreigroot]=eig(R);eigroot=diag(eigro
3、ot);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);predictval
4、ue=f2*fai;ima_pre=std_b*predictvalue+mean_b;1.子函數(shù):timeseries.m%timeseriesprogram%%thisprogramisusedtogeneratemeanvaluematrixf;function[f,x]=timeseries(data)%data--------theinputsequence(vector);%f------meanvaluematrixf;n=length(data);forL=1:n/2??nL=floor(n/L);??fori=1:
5、L??????sum=0;??????forj=1:nL????????sum=sum+data(i+(j-1)*L);????end????x{L,i}=sum/nL;??endendL=n/2;f=zeros(n,L);fori=1:L??rep=floor(n/i);??res=mod(n,i);??b=[x{i,1:i}];b=b';??f(1:rep*i,i)=repmat(b,rep,1);??ifres~=0??????c=rep*i+1:n;??????f(rep*i+1:end,i)=b(1:length(c));
6、??endend接上,seriesexpan.m%seriesexpan.m%theprogramisusedtogeneratethepredictionmatrixf;functionf=seriesexpan(data,step);%data----theinputsequence(vector)%setp----thepredictionnumber;n=length(data);forL=1:n/2??nL=floor(n/L);??fori=1:L??????sum=0;??????forj=1:nL????????su
7、m=sum+data(i+(j-1)*L);????end????x{L,i}=sum/nL;??endendL=n/2;f=zeros(n+step,L);fori=1:L??rep=floor((n+step)/i);??res=mod(n+step,i);??b=[x{i,1:i}];b=b';??f(1:rep*i,i)=repmat(b,rep,1);??ifres~=0??????c=rep*i+1:n+step;??????f(rep*i+1:end,i)=b(1:length(c));??endend