# How to plot CDF of a Poisson distribution in Mathematica

How to plot the following in Mathematica:

$$P = \sum_{k=C+1}^{\infty}\frac{e^{-C^\gamma} (C^\gamma)^k}{k!}$$

I want to plot $$P$$ versus $$C \log{C}$$ for a given $$\gamma$$ with logarithmic scale on Y-axis. In MATLAB, I'd calculate it as follows:

gamma = 0.75;
C = 1:1:20;
lambda = C .^ gamma;
p = 1 - poisscdf(C,lambda);
semilogy(C .* log(C), p);


It is worth noting two characteristic features of the question:

1. The sum is a complementary cumulative distribution function for a Poisson distribution: it's built in to Mathematica and needn't be computed explicitly.

2. The use of $C+1$ as a starting index in the sum, as well as the expression 1:1:20 in the code, indicate $C$ is considered an integer: this needs to be a discrete plot.

It can also help to draw clear parallels between the ΜATLAB approach and an idiomatic Mathematica approach. How about this?

Module[{c = Range[20], γ = 0.75, p},
p = {# Log[#], 1 - CDF[PoissonDistribution[#^γ], #]} & /@ c;
ListLogPlot[p]
]


• Much easier now. But, what about the logarithmic scale on the y-axis? I mean the ticks! May 2, 2012 at 14:19
• @Osama They are logarithmic! May 2, 2012 at 19:14

Here is what I would do:

p[c_, x_] = (Sum[Exp[-x] x^k/k!, {k, c + 1, Infinity}] //
FullSimplify)

With[{gamma = 0.75},
ParametricPlot[{c Log[c], p[c, c^gamma]}, {c, 1, 20},
AspectRatio -> 1]]


• How to make it logarithmic scale on y axes as in the Matlab code? I used Log[p[c, c^gamma]] but still can't edit the axes thing!! May 2, 2012 at 13:32
• cValues = Range[1, 20, 0.05]; ListLogPlot[{# Log[#], p[#, #^0.75]} & /@ cValues, PlotRange -> All] ? May 2, 2012 at 13:41
• Why things is much complicated in Mathematica than in Matlab! May 2, 2012 at 14:12
• Here's a more compact definition of p[c, x]: p[c_, x_] := GammaRegularized[c + 1, 0, x]. I don't understand why FullSimplify[] doesn't use GammaRegularized[] more frequently myself... May 2, 2012 at 14:25

This is only a minor variant on the existing answers, but it will hopefully be clearer to a novice user:

pp[c_?Positive, γ_] := {c Log[c], 1 - CDF[PoissonDistribution[c^γ], c]}
ListLogPlot[Table[pp[x, 0.75], {x, 1, 40}]]


But notice:

ListLogPlot[Table[pp[x, 0.75], {x, 1, 40, 0.02}], Joined -> True]


The function is defined for non-integer values of $c$, but includes a Floor expression.

Assuming[c > 0, Simplify[1 - CDF[PoissonDistribution[c^γ], c]]]
(*  ==> 1 - GammaRegularized[1 + Floor[c], c^γ]  *)


As J.M. pointed out in comments, the expression that results from this simplification can be further simplified to GammaRegularized[1 + Floor[c], 0, c^γ], but the presence of Floor[] in the result is clear even in the less-simplified version.

• Again: 1 - GammaRegularized[1 + Floor[c], c^γ] can be simplified further to GammaRegularized[1 + Floor[c], 0, c^γ]. Numerically, it's a good idea to be using the three-argument form GammaRegularized[] for situations like this... May 3, 2012 at 6:43