Effacer les filtres
Effacer les filtres

Poisson CDF output is all one value

22 vues (au cours des 30 derniers jours)
Michael Purcell
Michael Purcell le 12 Juil 2024 à 21:22
Commenté : Michael Purcell le 13 Juil 2024 à 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 commentaire
Umar
Umar le 12 Juil 2024 à 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.

Connectez-vous pour commenter.

Réponse acceptée

Paul
Paul le 12 Juil 2024 à 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 commentaire
Michael Purcell
Michael Purcell le 13 Juil 2024 à 10:36
Facepalm! Of course. Thanks, that explains everything.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by