2
$\begingroup$

I plotted the Poisson Distribution for various mean values (plot label and vertical line). The plots does not peak around the mean as the mean increase. Any advice to get the right plot, or at least the right distribution values?

Same when plotting the log of the distribution -s + n Log[s] - LogGamma[n + 1]

Plot of the Poisson Distribution for various mean deviating from the mean

Table[ListPlot[Table[PDF[PoissonDistribution[s], n], {n, Round[Max[s - 8 Sqrt[s], 0]], Round[s + 8 Sqrt[s]]}], PlotLabel -> s, GridLines -> {{s}, None}], {s, {50, 60, 70, 80, 100, 150}}]
$\endgroup$
  • 1
    $\begingroup$ Also try DiscretePlot, for example: Table[DiscretePlot[ PDF[PoissonDistribution[s], n], {n, Round[Max[s - 8 Sqrt[s], 0]], Round[s + 8 Sqrt[s]]}, PlotLabel -> s, GridLines -> {{s}, None}], {s, {50, 60, 70, 80, 100, 150}}] $\endgroup$ – becko Jun 11 at 8:41
8
$\begingroup$

Because of the way you are generating the lists. What you are plotting is just a list of "y" values without the corresponding "x", that with ListPlot are plotted by Mathematica from 1 to n (with n the number of elements). If you start the list from a "x" value larger than one, Mathematica still plots from 1 to n.

Try with the following code where I explicitly add the "x" values to the lists: this should fix the problem.

Table[ListPlot[
  Table[{n, PDF[PoissonDistribution[s], n]}, {n, 
    Round[Max[s - 8 Sqrt[s], 0]], Round[s + 8 Sqrt[s]]}]
  , PlotLabel -> s, GridLines -> {{s}, None}]
 , {s, {50, 60, 70, 80, 100, 150}}]
$\endgroup$
  • $\begingroup$ Well I see, I miss the x coordinate. Thank you. That is the answer! $\endgroup$ – jss Jun 11 at 7:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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