Directory[]
SetDirectory["/home/stump/Desktop/phy102/lesson12-probability_and_statistics"]
FileNames[]

The Poisson distribution
as the limit of the Binomial distribution

P1[n_,p_,r_]:=PDF[       BinomialDistribution[n,p] ,r ]
P2[n_,p_,r_]:=n!/(r!*(n-r)!)*p^r*(1-p)^(n-r)
P3[n_,p_,r_]:=PDF[ PoissonDistribution[n*p] ,r]

?PDF
?BinomialDistribution

?DiscretePlot

lbl={{Red,Text["Red: b.d. with n=10 and p=0.7",{10,0.28},{-1,1}]},
Text["Black: P.d. with μ = 7",{12,0.25},{-1,1}]};
{nx,px}={10,0.7}
pl1=DiscretePlot[P1[nx,px,r],{r,0,20},PlotStyle->{Thickness[0.01],Red},
ExtentSize->Full,
PlotRange->{All,{0,0.3}}];
pl2=DiscretePlot[P2[nx,px,r],{r,0,12}];
pl3=DiscretePlot[P3[nx,px,r],{r,0,20},PlotStyle->{Thickness[0.01],Black},
ExtentSize->0.5,PlotRange->{All,{0,0.3}}];
a1=Show[pl1,pl3,Graphics[lbl],Frame->True,FrameLabel->{"r","P[r]"}]

lbl={{Red,Text["Red: b.d. with n=20 and p=0.35",{10,0.28},{-1,1}]},
Text["Black: P.d. with μ = 7",{10,0.25},{-1,1}]};
{nx,px}={20,0.7/2}
pl1=DiscretePlot[P1[nx,px,r],{r,0,20},PlotStyle->{Thickness[0.01],Red},
ExtentSize->Full,PlotRange->{All,{0,0.3}}];
pl2=DiscretePlot[P2[nx,px,r],{r,0,12},PlotStyle->{PointSize[0.01],Blue}];
pl3=DiscretePlot[P3[nx,px,r],{r,0,20},PlotStyle->{Thickness[0.01],Black},
ExtentSize->0.5,PlotRange->{All,{0,0.3}}];
a2=Show[pl1,pl3,Graphics[lbl],Frame->True,FrameLabel->{"r","P[r]"}]

0.14*50

lbl={{Red,Text["Red: b.d. with n=50 and p=0.14",{10,0.28},{-1,1}]},
Text["Black: P.d. with μ = 7",{10,0.25},{-1,1}]};
{nx,px}={50,0.14}
pl1=DiscretePlot[P1[nx,px,r],{r,0,20},PlotStyle->{Thickness[0.01],Red},
ExtentSize->Full,PlotRange->{All,{0,0.3}}];
pl2=DiscretePlot[P2[nx,px,r],{r,0,12},PlotStyle->{PointSize[0.01],Blue}];
pl3=DiscretePlot[P3[nx,px,r],{r,0,20},PlotStyle->{Thickness[0.01][0.01],Black},
ExtentSize->0.5,PlotRange->{All,{0,0.3}}];
a3=Show[pl3,pl1,Graphics[lbl],Frame->True,FrameLabel->{"r","P[r]"}]

output=GraphicsGrid[{{a1},{a2},{a3}},ImageSize->Large]
Export["BinPoi.png",output,"PNG"]