资源描述
(1)%poisson分布图
clf,clear,
m=30;lambta1=60;lambta2=70;
a=30;b=110;
subplot(2,2,1)
for k=1:m
x=poissrnd(lambta1);
y=poisspdf(x,lambta1);
stem(x,y,'LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','red',...
'MarkerSize',5)
hold on
axis([a b 0 0.06])
grid on;
title('lambta=60')
end
subplot(2,2,3)
t=a:3:b;
f=poisspdf(t,lambta1);
plot(t,f,'--rs','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',3)
hold on
axis([a b 0 0.06])
grid on;
subplot(2,2,2)
for k=1:m
x=poissrnd(lambta2);
y=poisspdf(x,lambta2);
stem(x,y,'LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','red',...
'MarkerSize',5)
hold on
axis([a b 0 0.06])
grid on;
title('lambta=70')
end
subplot(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:200
j=n+1;
sy=0;
for x=0:200
%用累加的方法计算收益值
i=x+1;
if x<=n
sy=sy+(x*(a-b)-(b-c)*(n-x))*y(i);
elseif x>n
sy=sy+(a-b)*n*y(i);
end
end
sy(j)=sy;
plot(n,sy(j),'--rs','LineWidth',1,...
'MarkerEdgeColor','r',...
'MarkerFaceColor','g',...
'MarkerSize',2);
%画出购进量与收益值的函数图形
hold on
end
legend('lambta变化时收益的变化情况');
temp1=num2str(floor(lambta));
str=strcat('lambta=',temp1);
text(20,90,str,'FontSize',15);
%在坐标轴(20,90)处标注
hold off
axis([0 200 -10 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:11
supply=n*10;
sub(n)=0;
for i=1:365
if x1(i)<=y(1)
need=40;
elseif x1(i)<=y(2)
need=50;
elseif x1(i)<=y(3)
need=60;
elseif x1(i)<=y(4)
need=70;
elseif x1(i)<=y(5)
need=80;
elseif x1(i)<=y(6)
need=90;
elseif x1(i)<=y(7)
need=100;
else
need=110;
end
%确定某一天报纸的需求量
if supply>=need
sale=need;
remand=supply-need;
else
sale=supply;
remand=0;
end
%确定剩余量
sub(n)=sub(n)+a*sale-b*supply+c*remand;
end
%求购进量为n时一年内报纸的收益值
end
optneed=40;
optmoney=sub(4);
[40,sub(4)/365]
%购进量为40时平均每天报纸的收益值
for n=5:11
if sub(n)>=optmoney
optneed=n*10;
optmoney=sub(n);
end
[n,sub(n)/365]
end
[optneed,optmoney,optmoney/365]
%求最优购进量和最大收益值
(4)%lambta的取值对最大收益的影响
clear
a=2;b=1.3;c=0.2;j=0;
m=zeros(73,1);
for lambta=40:1:112
j=j+1;
x=40:10:110;
y=poisscdf(x,lambta);
x1=rand(365,1);
for n=4:11
supply=n*10;
sub(n)=0;
for i=1:365
if x1(i)<=y(1)
need=40;
elseif x1(i)<=y(2)
need=50;
elseif x1(i)<=y(3)
need=60;
elseif x1(i)<=y(4)
need=70;
elseif x1(i)<=y(5)
need=80;
elseif x1(i)<=y(6)
need=90;
elseif x1(i)<=y(7)
need=100;
else
need=110;
end
if supply>=need
sale=need;
remand=supply-need;
else
sale=supply;
remand=0;
end
sub(n)=sub(n)+a*sale-b*supply+c*remand;
end
end
optneed=40;
optmoney=sub(4);
%[40,sub(4)/365];
for n=5:11
if sub(n)>=optmoney
optneed=n*10;
optmoney=sub(n);
end
%[n,sub(n)/365]
end
[optneed,optmoney,optmoney/365]
m(j)=optmoney;
end
la=40:1:112;
plot(la,m)
title('lambta取不同值时对最大收益的影响')
(4)%在每增加0.1元卖价则降低d份需求量的条件下,价格与收益的关系
clear
b=1.3;c=0.2;
d=4;
lambta=70;
x=40:10:110;
y=poisscdf(x,lambta);
x1=rand(365,1);
m=zeros(16,1);
j=0;
for a=1.5:0.1:3
j=j+1;
for n=4:11
supply=n*10;
sub(n)=0;
for i=1:365
if x1(i)<=y(1)
need=40-d*j; %每增加0.1元卖价,则降低d份需求量
elseif x1(i)<=y(2)
need=50-d*j;
elseif x1(i)<=y(3)
need=60-d*j;
elseif x1(i)<=y(4)
need=70-d*j;
elseif x1(i)<=y(5)
need=80-d*j;
elseif x1(i)<=y(6)
need=90-d*j;
elseif x1(i)<=y(7)
need=100-d*j;
else
need=110-d*j;
end
if need<0
need=0;
end
if supply>=need
sale=need;
remand=supply-need;
else
sale=supply;
remand=0;
end
sub(n)=sub(n)+a*sale-b*supply+c*remand;
end
end
optneed=40;
optmoney=sub(4);
[40,sub(4)/365];
for n=5:11
if sub(n)>=optmoney
optneed=n*10;
optmoney=sub(n);
end
[n,sub(n)/365];
end
[optneed,optmoney/365]
m(j)=optmoney/365;
end
n=1.5:0.1:3;
plot(n,m,'r.')
展开阅读全文