数学建模必备程序

数学建模必备程序

ID:30887475

大小:223.63 KB

页数:19页

时间:2019-01-03

数学建模必备程序_第1页
数学建模必备程序_第2页
数学建模必备程序_第3页
数学建模必备程序_第4页
数学建模必备程序_第5页
资源描述:

《数学建模必备程序》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、一基于均值生成函数时间序列预测算法程序1.predict」un.m为主程序;2.timeseries.m和serie**pan.m为调川的子程序functionima_pre=predict_fun(b,step)%mainprograminvokestimeseries.mandserie**pan.m%inputparameters:%bthetrainingdata(vector);%step-mberofpredictiondata;%outputparameters:%ima_pre--thepredi

2、ctiondata(vector);old_b=b;mean_b=sum(old_b)/length(old_b);std_b=std(old_b);old_b=(oId_b-mean_b)/std_b;[f,x]=timeseries(old_b);old_f2=serie**pan(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(e

3、igroot);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」ai=inv(V,*V)*V,*old_b;eigvector=eigvector(1:m,1:m);fai=eigvector*old_fai;f2=oldI_f2(:,1

4、:m);predictvalue=f2*fai;ima_pre=std_b*predictvalue+mean_b;1•子函数:timeseries.m%timeseriesprogram%%thisprogramisusedtogeneratemeanvaluematrixf;function[f,x]=timeseries(data)%datatheinputsequenee(vector);%f-meanvaluematrixf;n=length(data);forL=1:n/2nL=floor(n/L);

5、fori=1:Lsum=0;forj=1:nLsum=sum+data(i+(j-1)*L);endx{L,i}=sum/nL;endendL=n/2;f=zeros(n3L);fori=1:Lrep=floor(n/i);res=mod(n,i);b=[x{i,1:i}];b=b';f(1:rep*i,i)=repmat(b,rep,1);ifres~=0c=rep*i+1:n;f(rep*i+1:end,i)=b(1:length(c));endend%serie**pan.m%theprogramisuse

6、dtogeneratethepredictionmatrixf;functionf=serieipan(data,step);%data-•-theinputsequenee(vector)%setp-—thepredictionnumber;n=length(data);forL=1:n/2nL=floor(n/L);fori=1:Lsum=0;forj=1:nLsum=sum+data(i+(j-1)*L);endx{L,i}=sum/nL;endendL=n/2;f=zeros(n+step丄);fori=

7、1:Lrep=floor((n+step)/i);res=mod(n+step3i);b=[x{i,1:i}];b=b,;f(1:rep*ij)=repmat(b,rep,1);ifres~=0c=rep*i+1:n+step;f(rep*i+1:end,i)=b(1:length(c));endend二最短路Dijkstra算法%dijkstraalgorithmcodeprogram%%theshortestpathlengthalgorithmfunction[path,short_distanee]=Sh

8、ortF^th_Dijkstra(Input_weight,start,endpoint)%Inputparameters:%Input_weighttheinputnodeweight!%startthestartnodenumber;%endpointtheendnodenumber;%Outputparameters:%paththeshortestlenghtpa

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。