Binomial Distributions

one example

Clear[n,p,x];
n=20;p=.4;
ListPlot[Table[PDF[BinomialDistribution[n,p],x],{x,0,n}],PlotStyle->PointSize[0.02`],PlotRange->{-.05,.5},AxesLabel->{"x","p(x)"},PlotLabel->"Binomial: n="<>ToString[n]<>", p="<>ToString[p]]
ListPlot[Table[CDF[BinomialDistribution[n,p],x],{x,0,n}],PlotStyle->PointSize[0.02`],PlotRange->{-.05,1.05},AxesLabel->{"x","p(x)"},PlotLabel->"Cumulative Binomial: n="<>ToString[n]<>", p="<>ToString[p]]

for fixed n, change p and see the effect.

Clear[n,p,x];
Clear[titlePDF,titleCDF];
titlePDF[n_,p_] := "Binomial:  n="<>ToString[n]<>", p="<>ToString[p]<>", E[X]="<>ToString[n*p]<>", V[X]="<>ToString[n*p*(1-p)];
titleCDF[n_,p_] := "Cumulative Binomial:  n="<>ToString[n]<>", p="<>ToString[p]<>", E[X]="<>ToString[n*p]<>", V[X]="<>ToString[n*p*(1-p)];

Clear[n,p,x];
n=40;
Manipulate[
ListPlot[Table[PDF[BinomialDistribution[n,p],x],{x,0,n}],PlotStyle->PointSize[0.02`],PlotRange->{{0,1.1n},{-.05,.3}},AxesLabel->{"x","p(x)"},PlotLabel->titlePDF[n,p]],{p,.1,.9,.05}]

Manipulate[
ListPlot[Table[CDF[BinomialDistribution[n,p],x],{x,0,n}],PlotStyle->PointSize[0.02`],PlotRange->{{0,1.1n},{-.05,1.05}},AxesLabel->{"x","p(x)"},PlotLabel->titleCDF[n,p]],{p,.1,.9,.05}]

for fixed p, change n and see the effect.

Clear[n,p,x];
p=.8;
Manipulate[
ListPlot[Table[PDF[BinomialDistribution[n,p],x],{x,0,n}],PlotStyle->PointSize[0.02`],PlotRange->{{0,50},{-.05,.5}},AxesLabel->{"x","p(x)"},PlotLabel->titlePDF[n,p]],{n,5,40,5}]

Manipulate[
ListPlot[Table[CDF[BinomialDistribution[n,p],x],{x,0,n}],PlotStyle->PointSize[0.02`],PlotRange->{{0,50},{-.05,1.05}},AxesLabel->{"x","p(x)"},PlotLabel->titleCDF[n,p]],{n,5,40,5}]