资源描述:
《浅析需求量服从poisson分布的报童问题》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、(1)%poisson分布图clf,clear,m=30;lambta1=60;lambta2=70;a=30;b=110;subplot(2,2,1)fork=1:mx=poissrnd(lambta1);y=poisspdf(x,lambta1);stem(x,y,'LineWidth',2,...'MarkerEdgeColor','k',...'MarkerFaceColor','red',...'MarkerSize',5)holdonaxis([ab00.06])gridon;title('lambta=60')endsubplot(2,2,3)t=a:3:b;f=p
2、oisspdf(t,lambta1);plot(t,f,'--rs','LineWidth',2,...'MarkerEdgeColor','k',...'MarkerFaceColor','g',...'MarkerSize',3)holdonaxis([ab00.06])gridon;subplot(2,2,2)fork=1:mx=poissrnd(lambta2);y=poisspdf(x,lambta2);stem(x,y,'LineWidth',2,...'MarkerEdgeColor','k',...'MarkerFaceColor','red',...'Marke
3、rSize',5)holdonaxis([ab00.06])gridon;title('lambta=70')endsubplot(2,2,4)t=a:3:b;f=poisspdf(t,lambta2);y0=max(f)+0.1;plot(t,f,'--rs','LineWidth',2,...'MarkerEdgeColor','k',...'MarkerFaceColor','g',...'MarkerSize',3)axis([ab00.06])gridon;(2)%购进量随收益值变化的动画图线a=2;b=1.3;c=0.2;forlambta=40:110;x=0:20
4、0;y=poisspdf(x,lambta);%需求量的概率服从泊松分布forn=0:200j=n+1;sy=0;forx=0:200%用累加的方法计算收益值i=x+1;ifx<=nsy=sy+(x*(a-b)-(b-c)*(n-x))*y(i);elseifx>nsy=sy+(a-b)*n*y(i);endendsy(j)=sy;plot(n,sy(j),'--rs','LineWidth',1,...'MarkerEdgeColor','r',...'MarkerFaceColor','g',...'MarkerSize',2);%画出购进量与收益值的函数图形holdonen
5、dlegend('lambta变化时收益的变化情况');temp1=num2str(floor(lambta));str=strcat('lambta=',temp1);text(20,90,str,'FontSize',15);%在坐标轴(20,90)处标注holdoffaxis([0200-10100]);set(gca,'XTick',0:20:200);%设置x轴网格线set(gca,'YTick',-10:10:100);gridon;drawnow;end(3)%lambta取70时不同购进量对应的收益值a=2;b=1.3;c=0.2;lambta=70;x=40:1
6、0:110;y=poisscdf(x,lambta);%不同需求量所对应的概率值x1=rand(365,1);%随机产生一年内的概率,从而确定某一天的报纸的需求量forn=4:11supply=n*10;sub(n)=0;fori=1:365ifx1(i)<=y(1)need=40;elseifx1(i)<=y(2)need=50;elseifx1(i)<=y(3)need=60;elseifx1(i)<=y(4)need=70;elseifx1(i)<=y(5)need=80;elseifx1(i)<=y(6)need=90;elseifx1(i)<=y(7)need=100;
7、elseneed=110;end%确定某一天报纸的需求量ifsupply>=needsale=need;remand=supply-need;elsesale=supply;remand=0;end%确定剩余量sub(n)=sub(n)+a*sale-b*supply+c*remand;end%求购进量为n时一年内报纸的收益值endoptneed=40;optmoney=sub(4);[40,sub(4)/365]%购进量为40时平均每天报纸的收益值forn=5:11ifsub(