1、二项分布
%% 二项分布:p=binopdf(x,n,p);p=binocdf(x,n,p);
clear;close all;clc;
x = [0:1:40];
y = binopdf(x,20,0.5);
yc = binocdf(x,20,0.5);
plot(x,y,'-*b');
hold on
y1 = binopdf(x,40,0.5);
yc1 = binocdf(x,40,0.5);
plot(x,y1,'-*r');
y2 = binopdf(x,40,0.8);
yc2 = binocdf(x,40,0.8);
plot(x,y2,'-*k');
legend('n=20,p=0.5','n=40,p=0.5','n=40,p=0.8')
figure
plot(x,yc,'-*b');
hold on
plot(x,yc1,'-*r');
plot(x,yc2,'-*k');
2、泊松分布
%% 二项分布:p=poisspdf(x,lambda);p=poisscdf(x,lambda);
clear;close all;clc;
x = 0:1:20;
y = poisspdf(x,5)
y1 = poisspdf(x,7)
plot(x,y,'-*r')
hold on
plot(x,y1,'-*k')
legend('lambda=5','lambda=7')
yc = poisscdf(x,5)
yc1 = poisscdf(x,7)
figure
plot(x,yc,'-*r')
hold on
plot(x,yc1,'-*k')
legend('lambda=5','lambda=7')