matlab指数增长和阻滞增长拟合代码

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

02468101214050010001500时间段公众号总量(万)资讯类原始数据指数增长模型阻滞增长模型024681012140100200300400时间段公众号总量(万)生活类原始数据指数增长模型阻滞增长模型024681012140100200300时间段公众号总量(万)娱乐类原始数据指数增长模型阻滞增长模型024681012140100200300时间段公众号总量(万)其他原始数据指数增长模型阻滞增长模型代码:t=1:13;x=[3.04,6.63,11.13,28.43,49.22,87.85,134.11,200.00,208.69,303.03,410.73,580.00,728.57];c=[0.40,0.97,2.31,4.45,7.63,10.11,19.86,33.44,38.03,75.07,112.08,152.39,226.55];d=[2.06,2.35,3.17,8.06,15.22,28.82,43.31,54.67,55.83,75.26,102.01,174.05,200.95];e=[0.54,1.18,1.98,5.06,8.77,15.65,23.89,36.63,37.17,53.98,73.16,123.31,159.78];%指数增长模型y=log(x);cc=log(c);dd=log(d);ee=log(e);a=polyfit(t,y,1);h=polyfit(t,cc,1);i=polyfit(t,dd,1);k=polyfit(t,ee,1);r=a(1);r2=h(1);r3=i(1);r4=k(1);x0=exp(a(2));x1=x0*exp(r*t);c0=exp(h(2));c1=c0*exp(r2*t);d0=exp(i(2));d1=d0*exp(r3*t);e0=exp(k(2));e1=e0*exp(r4*t);%阻滞增长模型f=@(a,t)a(1)./(1+(a(1)/x(1)-1)*exp(-a(2)*(t-t(1))));f=@(h,t)h(1)./(1+(h(1)/c(1)-1)*exp(-h(2)*(t-t(1))));f=@(i,t)i(1)./(1+(i(1)/d(1)-1)*exp(-i(2)*(t-t(1))));f=@(k,t)k(1)./(1+(k(1)/e(1)-1)*exp(-k(2)*(t-t(1))));a=lsqcurvefit(f,[8001],t,x);h=lsqcurvefit(f,[8001],t,c);i=lsqcurvefit(f,[8001],t,d);k=lsqcurvefit(f,[8001],t,e);figure(1);subplot(2,1,1);plot(t,x,'o',t,x1,'r:.');x2=f(a,t);plot(t,x,'o',t,x1,'r:.',t,x2,'g*--')legend('原始数据','指数增长模型','阻滞增长模型',2)xlabel时间段ylabel公众号总量(万)title('资讯类');figure(1)subplot(2,1,2);plot(t,c,'o',t,c1,'r:.');c2=f(h,t);plot(t,c,'o',t,c1,'r:.',t,c2,'g*--')legend('原始数据','指数增长模型','阻滞增长模型',2)xlabel时间段ylabel公众号总量(万)title('生活类');figure(2)subplot(2,1,1);plot(t,d,'o',t,d1,'r:.');d2=f(i,t);plot(t,d,'o',t,d1,'r:.',t,d2,'g*--')legend('原始数据','指数增长模型','阻滞增长模型',2)xlabel时间段ylabel公众号总量(万)title('娱乐类');figure(2)subplot(2,1,2);plot(t,e,'o',t,e1,'r:.');e2=f(k,t);plot(t,e,'o',t,e1,'r:.',t,e2,'g*--')legend('原始数据','指数增长模型','阻滞增长模型',2)xlabel时间段ylabel公众号总量(万)title('其他');)1(1xkebar参数资讯类生活类娱乐类其他类公众号总量a1.1584.8111365610459.22254b52.476715.301510888.9164k2461.02313.0166.0174.0182.005101520250100200300400500600700800xe各个领域公众号对比图公众号总量资讯类生活类娱乐类其他类程序代码:x=[1:2:26]';y=[3.04,6.63,11.13,28.43,49.22,87.85,134.11,200.00,208.69,303.03,410.73,580.00,728.57]';b=[2.04,2.14,3.68,10.86,17.60,33.27,47.05,75.26,77.66,88.72,123.48,130.25,141.29]';c=[0.40,0.97,2.31,4.45,7.63,10.11,19.86,33.44,38.03,75.07,112.08,152.39,226.55]';d=[2.06,2.35,3.17,8.06,15.22,28.82,43.31,54.67,55.83,75.26,102.01,174.05,200.95]';e=[0.54,1.18,1.98,5.06,8.77,15.65,23.89,36.63,37.17,53.98,73.16,123.31,159.78]';st_=[500300.2];ft_=fittype('a0/(1+b0*exp(-k0*(x-1)))',...'dependent',{'y'},'independent',{'x'},...'coefficients',{'a0','b0','k0'});cf_=fit(x,y,ft_,'Startpoint',st_)plot(cf_,'fit',0.95);holdon,plot(x,y,'ro')f1t_=fittype('a1/(1+b1*exp(-k1*(x-1)))',...'dependent',{'b'},'independent',{'x'},...'coefficients',{'a1','b1','k1'});c1f_=fit(x,b,f1t_,'Startpoint',st_)plot(c1f_,'fit',0.95);holdon,plot(x,b,'g*')f2t_=fittype('a2/(1+b2*exp(-k2*(x-1)))',...'dependent',{'c'},'independent',{'x'},...'coefficients',{'a2','b2','k2'});c2f_=fit(x,c,f2t_,'Startpoint',st_)plot(c2f_,'fit',0.95);holdon,plot(x,c,'b+')f3t_=fittype('a3/(1+b3*exp(-k3*(x-1)))',...'dependent',{'d'},'independent',{'x'},...'coefficients',{'a3','b3','k3'});c3f_=fit(x,d,f3t_,'Startpoint',st_)plot(c3f_,'fit',0.95);holdon,plot(x,d,'*')f4t_=fittype('a4/(1+b4*exp(-k4*(x-1)))',...'dependent',{'e'},'independent',{'x'},...'coefficients',{'a4','b4','k4'});c4f_=fit(x,e,f4t_,'Startpoint',st_)plot(c4f_,'fit',0.95);holdon,plot(x,e,'yo')

1 / 6
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功