Clear Filters
Clear Filters

Poisson CDF output is all one value

22 views (last 30 days)
Michael Purcell
Michael Purcell on 12 Jul 2024 at 21:22
Commented: Michael Purcell on 13 Jul 2024 at 10:36
I'm creating a Poisson distribution. I then want to produce a cdf evaluated at an array of values using this distribution. However, the output of the cdf matlab function when applied to a Poisson distribution is giving me all one value. I can alter that value by changing lambda of the Poisson distribution, but it's still all one and the same.
This is my first time using Poisson distributions in Matlab, so admittedly there is a strong possiblity there is some user error involved here, but after staring at this code and rewriting it for the last two hours I'm stumped.
The code is below, along with a plot of the evaluated cdf over an array that includes 5000 points regularly spaced from 0.00001 to 0.05. The CDF value is roughly 0.95 for all evaluated points, but it should be a nice smooth 'S' shape starting at 0 and climbing up as the XX value increases. Why am I getting this nonsensical output?
Computer is a Dell laptop running Windows 10.
XX = 0.00001:0.00001:0.05;
p = makedist('Poisson','lambda',0.05);
C = cdf(p,XX);
plot(C)
  1 Comment
Umar
Umar on 12 Jul 2024 at 21:59

Hi Michael,

My suggestions are listed below. Adjust the lambda parameter to observe changes in the CDF curve. Experiment with different lambda values to achieve the expected curve shape, consider adjusting the range of values in XX to cover a broader spectrum that showcases the CDF curve's behavior more accurately. I also potentially improve the visualization of the Poisson distribution's CDF using your code.

XX = 0.00001:0.00001:0.05;

lambda = 0.05;

C = poisscdf(XX, lambda);

plot(XX, C);

Please see attached plot.

Please let me know if you have any further questions.

Sign in to comment.

Accepted Answer

Paul
Paul on 12 Jul 2024 at 22:55
Hi Michael,
The Poisson Distribution is a distribution of a discrete random variable that takes on only integer values >= 0. For a discrete random variable, the cdf is a staircase function that is constant between the values that variable can actually take. In this instance, those values are the integers >= 0, hence for all your XX values you're gettng the constant value of the CDF between 0 and 1. Extending the XX values further shows this
XX = 0:0.01:3;
p = makedist('Poisson','lambda',0.05);
C = cdf(p,XX);
plot(XX,C)
  1 Comment
Michael Purcell
Michael Purcell on 13 Jul 2024 at 10:36
Facepalm! Of course. Thanks, that explains everything.

Sign in to comment.

More Answers (0)

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!