Comparing Binomial and Normal Distributions

approxGraph[n_, p_,maxX_,maxY_]:=Show[
ListPlot[Table[PDF[BinomialDistribution[n,p],x],
{x,0,n}],
PlotStyle->{PointSize[.02],Red},
PlotRange->{{0,maxX},{0,maxY}}   ],
Plot[PDF[NormalDistribution[n*p,(Sqrt[n*p*(1-p)])],x],
{x,0,2*n},PlotRange->{{0,maxX},{0,maxY}}],
PlotLabel->StringJoin["n=",ToString[n],", p=",ToString[p]]
];

approxGraph[20,.4,20,.5]

Manipulate[approxGraph[n,.2,40,.5],{n,5,100,10}]

n=20;p=.4;
Print["n = ",n,".    p = ",p,"     μ = ",n*p,
"     σ = ",(Sqrt[n*p*(1-p)])]
TableForm[Table[
{x,PDF[BinomialDistribution[n,p],x],
PDF[NormalDistribution[n*p,(Sqrt[n*p*(1-p)])],x],PDF[NormalDistribution[n*p,(Sqrt[n*p*(1-p)])],x]-PDF[BinomialDistribution[n,p],x]},
{x,0,n}]]
Clear[n,p]

continuity correction

n=20;p=.4;
Print["n = ",n,".    p = ",p,"     μ = ",n*p,
"     σ = ",(Sqrt[n*p*(1-p)])]
TableForm[Table[
{x,PDF[BinomialDistribution[n,p],x],
CDF[NormalDistribution[n*p,(Sqrt[n*p*(1-p)])],x+.5]-
CDF[NormalDistribution[n*p,(Sqrt[n*p*(1-p)])],x-.5],
CDF[NormalDistribution[n*p,(Sqrt[n*p*(1-p)])],x+.5]-
CDF[NormalDistribution[n*p,(Sqrt[n*p*(1-p)])],x-.5]-PDF[BinomialDistribution[n,p],x]},
{x,0,n}]]
Clear[n,p]

approxGraph2[n_, p_,maxX_,maxY_]:=Show[
ListPlot[Table[PDF[BinomialDistribution[n,p],x],
{x,0,n}],
PlotStyle->{PointSize[.02],Red},
PlotRange->{{0,maxX},{0,maxY}}   ],
Plot[CDF[NormalDistribution[n*p,(Sqrt[n*p*(1-p)])],x+.5]-CDF[NormalDistribution[n*p,(Sqrt[n*p*(1-p)])],x-.5],
{x,0,2*n},PlotRange->{{0,maxX},{0,maxY}}],
PlotLabel->StringJoin["n=",ToString[n],", p=",ToString[p]]
];

approxGraph2[20,.4,20,.5]

Manipulate[approxGraph2[n,.2,40,.5],{n,5,100,10}]

n=20;p=.4;
Print["n = ",n,".    p = ",p,"     μ = ",n*p,
"     σ = ",(Sqrt[n*p*(1-p)])]
TableForm[Table[
{x,PDF[NormalDistribution[n*p,(Sqrt[n*p*(1-p)])],x]-PDF[BinomialDistribution[n,p],x],
CDF[NormalDistribution[n*p,(Sqrt[n*p*(1-p)])],x+.5]-
CDF[NormalDistribution[n*p,(Sqrt[n*p*(1-p)])],x-.5]-PDF[BinomialDistribution[n,p],x],PDF[NormalDistribution[n*p,(Sqrt[n*p*(1-p)])],x]-
(CDF[NormalDistribution[n*p,(Sqrt[n*p*(1-p)])],x+.5]-
CDF[NormalDistribution[n*p,(Sqrt[n*p*(1-p)])],x-.5])},
{x,0,n}]]
Clear[n,p]

Clear[CombapproxGraph]
CombapproxGraph[n_, p_,maxX_,maxY_]:=Show[
ListPlot[Table[PDF[BinomialDistribution[n,p],x],
{x,0,n}],
PlotStyle->{PointSize[.02],Red},Joined->True,
PlotRange->{{0,maxX},{0,maxY}}   ],
Plot[PDF[NormalDistribution[n*p,(Sqrt[n*p*(1-p)])],x],
{x,0,2*n},PlotRange->{{0,maxX},{0,maxY}},PlotStyle->DotDashed],
Plot[CDF[NormalDistribution[n*p,(Sqrt[n*p*(1-p)])],x+.5]-CDF[NormalDistribution[n*p,(Sqrt[n*p*(1-p)])],x-.5],
{x,0,2*n},PlotRange->{{0,maxX},{0,maxY}},PlotStyle->Dashed],
PlotLabel->StringJoin["n=",ToString[n],", p=",ToString[p]]
];

Manipulate[CombapproxGraph[n,.2,40,.5],{n,5,100,10}]