n = 20
p = 0.2
x1 = 0:n
geo = nbinpdf(x1,1,p)
figure(1)
bar(x1,geo)

geosamp = nbinrnd(1,p,1,100)
figure(5)
geohist = hist(geosamp,x1)
bar(x1,geohist)

figure(2)
pois = poisspdf(x1,5)
bar(x1,pois)

figure(3)
bino = binopdf(x1,n,p)

figure(4)
poissamp = poissrnd(5,1,100)
poisshist = hist(poissamp,x1)
bar(x1,poisshist)

r = 3
p = 0.6
nbin = nbinpdf(x1,r,p)
figure(6)
bar(x1,nbin)

nbinsamp = nbinrnd(r,p,1,100)
figure(7)
nbinhist = hist(nbinsamp,x1)
bar(x1,nbinhist)
