1、(1)%poisson 分布图clf,clear,m=30;lambta1=60;lambta2=70;a=30;b=110; subplot(2,2,1)for k=1:mx=poissrnd(lambta1);y=poisspdf(x,lambta1);stem(x,y,LineWidth,2,.MarkerEdgeColor,k,.MarkerFaceColor,red,.MarkerSize,5)hold onaxis(a b 0 0.06)grid on;title(lambta=60)endsubplot(2,2,3)t=a:3:b;f=poisspdf(t,lambta1);pl
2、ot(t,f,-rs,LineWidth,2,.MarkerEdgeColor,k,.MarkerFaceColor,g,.MarkerSize,3)hold onaxis(a b 0 0.06)grid on;subplot(2,2,2)for k=1:mx=poissrnd(lambta2);y=poisspdf(x,lambta2);stem(x,y,LineWidth,2,.MarkerEdgeColor,k,.MarkerFaceColor,red,.MarkerSize,5)hold onaxis(a b 0 0.06)grid on;title(lambta=70)endsubp
3、lot(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(a b 0 0.06)grid on;(2)%购进量随收益值变化的动画图线a=2;b=1.3;c=0.2;for lambta=40:110;x=0:200; y=poisspdf(x,lambta); %需求量的概率服从泊松分布for n=0:200j=n+1;sy=0;for x=0:200 %用累加的方法计算收益值i=x
4、+1; if xnsy=sy+(a-b)*n*y(i); end endsy(j)=sy;plot(n,sy(j),-rs,LineWidth,1,.MarkerEdgeColor,r,.MarkerFaceColor,g,.MarkerSize,2); %画出购进量与收益值的函数图形hold onendlegend(lambta 变化时收益的变化情况);temp1=num2str(floor(lambta);str=strcat(lambta=,temp1);text(20,90,str,FontSize,15); %在坐标轴(20 ,90)处标注hold offaxis(0 200 -10
5、 100);set(gca,XTick,0:20:200); %设置 x 轴网格线set(gca,YTick,-10:10:100);grid on;drawnow; end(3)%lambta 取 70 时不同购进量对应的收益值a=2;b=1.3;c=0.2;lambta=70;x=40:10:110;y=poisscdf(x,lambta); %不同需求量所对应的概率值x1=rand(365,1);%随机产生一年内的概率,从而确定某一天的报纸的需求量for n=4:11supply=n*10;sub(n)=0;for i=1:365if x1(i)=needsale=need;remand
6、=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 时平均每天报纸的收益值for n=5:11if sub(n)=optmoneyoptneed=n*10; optmoney=sub(n);endn,sub(n)/365endoptneed,optmoney,optmoney/365%求最优购进量和最大收益值(4)%lambta
7、的取值对最大收益的影响cleara=2;b=1.3;c=0.2;j=0;m=zeros(73,1);for lambta=40:1:112j=j+1;x=40:10:110;y=poisscdf(x,lambta);x1=rand(365,1);for n=4:11supply=n*10;sub(n)=0;for i=1:365if x1(i)=needsale=need;remand=supply-need;elsesale=supply;remand=0;endsub(n)=sub(n)+a*sale-b*supply+c*remand;endendoptneed=40;optmoney=
8、sub(4);%40,sub(4)/365;for n=5:11if sub(n)=optmoneyoptneed=n*10; optmoney=sub(n);end%n,sub(n)/365endoptneed,optmoney,optmoney/365m(j)=optmoney;endla=40:1:112;plot(la,m)title(lambta 取不同值时对最大收益的影响 )(4)%在每增加 0.1 元卖价则降低 d 份需求量的条件下,价格与收益的关系clearb=1.3;c=0.2;d=4;lambta=70;x=40:10:110;y=poisscdf(x,lambta);x1
9、=rand(365,1);m=zeros(16,1);j=0;for a=1.5:0.1:3j=j+1;for n=4:11supply=n*10;sub(n)=0;for i=1:365if x1(i)=needsale=need;remand=supply-need;elsesale=supply;remand=0;endsub(n)=sub(n)+a*sale-b*supply+c*remand;end endoptneed=40;optmoney=sub(4);40,sub(4)/365;for n=5:11if sub(n)=optmoneyoptneed=n*10;optmoney=sub(n);endn,sub(n)/365;endoptneed,optmoney/365m(j)=optmoney/365;endn=1.5:0.1:3;plot(n,m,r.)