Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm trying to ilustrate the difficulties in assigning bins to a data set and then running a comparison of the bins against a binomial distribution for all values- n, p. The code I have so far is (mostly thanks to Nasser):

Manipulate[Show[Histogram[dataB, {-0.5, 7.5, c}, "PDF"], 
  DiscretePlot[PDF[BinomialDistribution[n, p], x], {x, 0, 20}, 
   PlotStyle -> PointSize[Large]], ImagePadding -> All],
  {{c, 8, "Column Width"}, 0, 4, .1, Appearance -> "Labeled"},
  {{n, 7, "Number Of Quarters"}, 1, 20, 1, Appearance -> "Labeled"},
  {{p, 0.5, "Fair Coin Toss"}, 0, 1, 0.01, Appearance -> "Labeled"}]

The remaining problem, scaling the number of quarters in the binomial to the width of the X axis. Right now my X axis ranges from 0 to 7.5 in agreement with the range of the numbers in my data set. I think I need two X axes. One to illustrate the range of the numbers in my data set. And a second X axis to illustrate the number of quarters in the binomial ensemble (1 to 20). That's what I think. @Nasser

share|improve this question
1  
What are the variables you want to control with the slider bars? –  Pickett Aug 19 '13 at 18:55
1  
what is your control variables? i.e. what are the parameters you want to change? The first question to ask when making a Manipulate is: What do I want to control? –  Nasser Aug 19 '13 at 18:55

2 Answers 2

I have replaced your dataA with some live value,

Manipulate[{Histogram[
   RandomVariate[NormalDistribution[s, f], 200], {-0.5, 6.5, 1}, 
   "PDF"], DiscretePlot[PDF[BinomialDistribution[a, b], x], {x, 0, 7},
    PlotStyle -> PointSize[Large]]}, {a, 1, 10, 1}, {b, 0, 1, .1}, {s,
   0.1, 1, .1}, {f, 0.1, 1, .01}]
share|improve this answer

If you need additional controls, need to be more specific.

Manipulate[
 Show[Histogram[dataA, {-0.5, 6.5, 1}, "PDF"], 
  DiscretePlot[PDF[BinomialDistribution[n, p], x], {x, 0, 7}, 
   PlotStyle -> PointSize[Large]], ImagePadding -> 10],
 {{n, 6, "how many trials?"}, 2, 20, 1, Appearance -> "Labeled"},
 {{p, .5, "success probabilty?"}, 0, 1, 0.01, Appearance -> "Labeled"},
 Initialization :>
  (
   dataA = RandomInteger[{-1, 7}, 100];
   )
 ]

Mathematica graphics

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.