I encountered this when I was trying to answer this question. I just can't understand why the following code will only give a line at $y=0$:

Plot[PDF[PolyaAeppliDistribution[7, 1/4], x], {x, 0, 35}, Axes -> {False, True}]

enter image description here

While with Evaluate I'll get the desired result:

Plot[Evaluate@PDF[PolyaAeppliDistribution[7, 1/4], x], {x, 0, 35}]

enter image description here

DiscretePlot, which is a function with Attributes similar to Plot, doesn't suffer this:

DiscretePlot[PDF[PolyaAeppliDistribution[7, 1/4], x], {x, 0, 35}]

enter image description here

nor do many other distributions, for example NormalDistribution:

Plot[PDF[NormalDistribution[7, 2], x], {x, 0, 35}]

enter image description here

I haven't do a complete test so I'm not sure if there's other distribution behaved like PolyaAeppliDistribution. Has it got any deep reasons? Or it's just a bug?

I'm using Mathematica 8, Windows Vista Home Basic 32-bit.

  • $\begingroup$ Same behavior in 9.0.1 on Win7. $\endgroup$ – Ymareth Jan 23 '14 at 11:08
  • $\begingroup$ You'll get the same result with other non-continuous distributions. Use DiscretePlot. $\endgroup$ – ciao Jan 23 '14 at 11:28
  • $\begingroup$ @rasher Oh, I see! Why not give an answer? $\endgroup$ – xzczd Jan 23 '14 at 11:39
  • $\begingroup$ @xzczd: Are you requesting I put the comment as an answer? I'll assume so and do so, if not let me know and I'll delete it. $\endgroup$ – ciao Jan 23 '14 at 12:06
  • $\begingroup$ @rasher Yeah, just enlarge it into an answer :) $\endgroup$ – xzczd Jan 23 '14 at 12:10

You'll get the same result with other non-continuous distributions. Use DiscretePlot.

You can observe that the under-the-covers behavior is different when you evaluate the PDF (use EvaluationMonitor), many more points are sampled. The plot showing up is a side-effect I've not investigated enough to explain. You can also set WorkingPrecision to 1, and you'll get a (rough) plot, since MM is basically forced into using values that actually have PDF values. In any case, Plot is not appropriate for non-continuous distribution PDF, just use DiscretePlot with Joined->True.

| improve this answer | |
  • $\begingroup$ The WorkingPrecision -> 1 method is interesting! And I take the liberty to add some further exploration to your answer, feel free to undo it if you don't like it. $\endgroup$ – xzczd Jan 23 '14 at 12:52
  • $\begingroup$ @xzczd: I'd rather you just post it as your own answer and accept it, completely re-writing someone else's answer in this way is... yes, please just post it as your own, feel free to use anything from my original answer, that's fine by me. $\endgroup$ – ciao Jan 23 '14 at 12:58
  • $\begingroup$ Undone. Sorry, I seemed to be a little excited 囧. $\endgroup$ – xzczd Jan 23 '14 at 13:16
  • $\begingroup$ @xzczd: No worries! $\endgroup$ – ciao Jan 24 '14 at 3:56

As @rasher mentioned, it's all because PolyaAeppliDistribution is a discrete distribution.

The PDF of non-continuous distributions only have non-zero values at discrete points. Still choose the PolyaAeppliDistribution as the example:

ListPlot[PDF[PolyaAeppliDistribution[7, 1/4], #] & /@ Range[0, 35, 1/10]]

enter image description here

The plot showing up when evaluating the PDF isn't that of the PDF of PolyaAeppliDistribution at all. In fact the expression is no longer a discrete function after evaluated:

PDF[PolyaAeppliDistribution[7, 1/4], x]
Piecewise[{{1/E^7, x == 0}, {(21 Hypergeometric1F1[1 - x, 2, -21])/(4^x*E^7), x > 0}}, 0]

Hypergeometric1F1 is continuous.

| improve this answer | |

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.