1
$\begingroup$

I have written code that simulates a M/M/1 queue system.

μ = 2; λ = 1.5; n = 5000;
t = 0; served = 0; sList = {}; QList = {};
tOutList = {}; tOutList[[0]] = 0;
Do[X = -Log[Random[]]/λ;
   Y = -Log[Random[]]/μ;
   t = t + X;
   tOut = Max[tOutList[[i - 1]], t] + Y;
   AppendTo[tOutList, tOut];
   AppendTo[sList, tOut - t];
   While[tOutList[[served + 1]] < t,
       served = served + 1;
       AppendTo[QList, {tOutList[[served]], i - 1 - served}
       ];
   ];
   AppendTo[QList, {t, i - served}];
   ,{i, 1, n}];

I tried to use a result from the above code to show the time spent by customers into the system a in histogram.

s = 0;
h = 
  Histogram[sList, 
    HistogramScale -> 1,
    HistogramCategories -> Table[i, {i, 0, 30, 0.25}]];
p = Plot[(μ - λ)Exp[-(μ - λ)*x], {x, 0, 10}];
Show[h, p]

But I get the following error From Show:

Show::gcomb: Could not combine the graphics objects in Show[Histogram[{0.4337989554392946`, 2.3556653158517125`,<<

How can I fix this?

Edit: My version of Mathematica is v6

$\endgroup$

closed as off-topic by MarcoB, m_goldberg, user9660, Yves Klett, Jens Jun 16 '16 at 18:40

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, m_goldberg, Community, Yves Klett, Jens
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ HistogramScale and HistogramCategories are no longer valid options for Histogram since version 7 of MMA. What version are you using? Where did you get the code? If you remove them, then Show will work fine; it is failing now because Histogram fails and does not return a graphics object. $\endgroup$ – MarcoB Jun 15 '16 at 19:55
  • $\begingroup$ @MarcoB It may be for the very old Histograms package (pre-v7). $\endgroup$ – Szabolcs Jun 15 '16 at 19:57
  • $\begingroup$ I forget to mention that my version of mathematica is 6 $\endgroup$ – ParisL Jun 15 '16 at 19:58
  • 2
    $\begingroup$ I think i found the solution. I needed to load the << Histograms;` package $\endgroup$ – ParisL Jun 15 '16 at 20:20
  • 1
    $\begingroup$ Glad that you found that out, but your previous answers confuse me. How could you have got a correct histogram plotted if you didn't have the package loaded at the time? Oh well.. $\endgroup$ – MarcoB Jun 15 '16 at 21:42

Browse other questions tagged or ask your own question.