Poisson CDF output is all one value

5 ビュー (過去 30 日間)
Michael Purcell
Michael Purcell 2024 年 7 月 12 日
コメント済み: Michael Purcell 2024 年 7 月 13 日
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 件のコメント
Umar
Umar 2024 年 7 月 12 日

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.

サインインしてコメントする。

採用された回答

Paul
Paul 2024 年 7 月 12 日
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 件のコメント
Michael Purcell
Michael Purcell 2024 年 7 月 13 日
Facepalm! Of course. Thanks, that explains everything.

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by