How can ı creat poisson random variables?

lambda = 75;
N = 0:200; %Number of people
P = poisspdf(N,lambda);
E=lambda;%expected value
V=lambda; %variance
bar(N,P,1);
xlabel('Observation');
ylabel('Probability');
I have a poisson distribution but I need to create poisson random numbers intead of N.CAn someone help me?
Thanks!

 採用された回答

Akira Agata
Akira Agata 2020 年 5 月 7 日

0 投票

You can generate random number by using poissonrnd function, like;
lambda = 75;
r = poissrnd(lambda);
Or, if you want to generate 1000-by-1 random number array, you can do it by:
r = poissrnd(lambda,1000,1);

3 件のコメント

Onur Metin Mertaslan
Onur Metin Mertaslan 2020 年 5 月 7 日
Thank you, I have a question, When I use "r", how can I plot it? I tried to use but I get error
Akira Agata
Akira Agata 2020 年 5 月 7 日
You mean, you want to create pdf plot from r ? Then, you can create it using histogram function with 'Normalization' option, like:
figure
histogram(r,'Normalization','pdf')
xlabel('Observation');
ylabel('Probability');
grid on
Onur Metin Mertaslan
Onur Metin Mertaslan 2020 年 5 月 8 日
Yes, Thank you so much!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeRandom Number Generation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by