# How Do I Convert A Binomial Distribution to a Smooth Histogram in a Manipulate?

Manipulate[BarChart[Table[PDF[BinomialDistribution[n, p], i], {i, 0, 20}],
PlotRange -> {{-.5, 21.5}, {-.1, 1}},
Epilog -> {PointSize[0.03], RGBColor[1, 0, 0], Point[{n*p + 1, 0}]},
ImageSize -> {450, 350}],
{{n, 10, "Variables"}, 1, 20, 1,Appearance -> "Labeled"},
{{p, .5, "Skew"}, 0, 1, Appearance -> "Labeled"}]


Ladies and Gentlemen! How do I convert the binomial distribution inside this Manipulate (above) to a SmoothHistogram? Or, more simply put, where do I insert the term SmoothHistogram in this script?

-

A few alternatives:

Using SmoothHistogram:

 Manipulate[ Module[{data = RandomVariate[BinomialDistribution[n, p], 500]},
Show[Plot[PDF[BinomialDistribution[n, p], x], {x, 0, 20},
PlotRange -> {{-.5, 21.5}, {-.1, 1}}, Evaluated -> True,
PlotStyle -> Directive[Thick, Blue],
Epilog -> {PointSize[0.03], RGBColor[1, 0, 0],
Point[{n*p + 1, 0}]}, ImageSize -> {450, 350}],
SmoothHistogram[data, PlotStyle -> Directive[Thick, Green]]]],
{{n,  10, "Variables"}, 1, 20, 1,  Appearance -> "Labeled"},
{{p, .5, "Skew"}, 0, 1, Appearance -> "Labeled"}]


Using SmoothKernelDistribution:

 Manipulate[Module[{data = RandomVariate[BinomialDistribution[n, p], 500]},
Plot[{PDF[BinomialDistribution[n, p], x],
PDF[SmoothKernelDistribution[data], x]}, {x, 0, 20},
PlotRange -> {{-.5, 21.5}, {-.1, 1}}, Evaluated -> True,
PlotStyle -> {Blue, Orange}, BaseStyle -> Thick,
Epilog -> {PointSize[0.03], RGBColor[1, 0, 0], Point[{n*p + 1, 0}]},
ImageSize -> {450, 350}]],
{{n, 10, "Variables"}, 1, 20, 1, Appearance -> "Labeled"},
{{p, .5, "Skew"}, 0, 1, Appearance -> "Labeled"}]


-