Tell me more ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Here is the code I thought might yield up two histograms and two binomial distributions plotted side by side:

Show[Histogram[dataA, {-0.5, 6.5, 1}, "PDF"], 
 Histogram[dataC, {4.5, 12.5, 1}, "PDF"], 
 DiscretePlot[PDF[BinomialDistribution[6, 0.5], x], {x, 0, 7}, 
  PlotStyle -> PointSize[Large]], 
 DiscretePlot[PDF[BinomialDistribution[7, 0.65], x - 5], {x, 5, 13}, 
  PlotStyle -> PointSize[Large]]]

No workee! I get the first Histogram and the first Binomial. But, unfortunately, the image terminates at a value of around 7.25.

share|improve this question

2 Answers

dataA = RandomVariate[BinomialDistribution[6, 0.5], 100];
dataC = RandomVariate[BinomialDistribution[7, 0.65], 100] + 5;
Show[Histogram[Evaluate[{dataA, dataC}], {-0.5, 13, 1}, "PDF"], 
DiscretePlot[PDF[BinomialDistribution[6, 0.5], x], {x, 0, 7}, 
PlotStyle -> PointSize[Large]], 
DiscretePlot[PDF[BinomialDistribution[7, 0.65], x - 5], {x, 5, 13}, 
PlotStyle -> PointSize[Large]]]

enter image description here

share|improve this answer
Dear Mister PatoCriollo: Thanks a bunch. That's exactly what I was looking for. @PatoCriollo – Joel Mayer Aug 6 at 18:44

enter image description here

  GraphicsGrid[{{Histogram[data, {-0.5, 6.5, 1}, "PDF"],
       DiscretePlot[PDF[BinomialDistribution[6, 0.5], x], {x, 0, 7}, 
        PlotStyle -> PointSize[Large]]}, {Histogram[data, {4.5, 12.5, 1}, 
        "PDF"], DiscretePlot[
        PDF[BinomialDistribution[7, 0.65], x - 5], {x, 5, 13}, 
        PlotStyle -> PointSize[Large]]}}]
share|improve this answer
Almost there! GraphicsGrid gives me four images in a side by side, left to right row. Histogram (1), Histogram (2), Binomial (1), Binomial (2). I'm needing the binomials to overlap the histograms. How do I do that? @Blackbird – Joel Mayer Aug 6 at 16:51
Sorry your question was little unclear to me, but this another answer will do. – Blackbird Aug 6 at 18:20

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.