Poisson Process for 500 variates

14 ビュー (過去 30 日間)
Zeynep Toprak
Zeynep Toprak 2020 年 5 月 13 日
コメント済み: Najme Benvari 2023 年 5 月 25 日
I would like to generate a code to produce a poisson process for N = 500 variates witk k is randomly between 1 and 10 and lambda = 12.
N = 500;
T = 1;
lambda = 12;
t = linspace(0, T, 100);
dt = t(2) - t(1);
S=cumsum([zeros(1,N); poissrnd(lambda*dt, length(t)-1, N) ]);
plot(t,S)
I generated this code by myself, bu I cannot use the random value of k between 1 and 10 , and 500-variates graph has too many lines, but I guess this result is totally wrong, how can I get rid of my mistakes and write the code properly?
Thanks a lot.
My second code is this
T = 1;
lambda = 12;
k=9;
t = linspace(0, T, 500);
for i = 1:500
f(i) = (lambda.^k) .* exp(-lambda) ./ factorial(k);
end
N = cumsum(f);
disp(N)
stairs(t,N(1:100))
But, again, the graph and estimations are totally wrong.

採用された回答

Abdullah Gül
Abdullah Gül 2020 年 5 月 31 日
Hello Zeynep,
You may try this.
lambda = 12;
nPeriods = 500;
dt = 0.1; %time steps
T = nPeriods*dt;
t = 0:0.1:T;
rng('default')
k=randi([1,10],1,nPeriods);
f = (lambda.^k).*exp(-lambda)./factorial(k); % Poission Dist.
Nd = cumsum(f);
N = [ 0 Nd(1:end) ]; % N(0)=0.
stairs(t,N)
If you decrease the Nperiods, you could see the stairs more precisely.
  3 件のコメント
Abdullah Gül
Abdullah Gül 2020 年 5 月 31 日
The difference between them comes from randomness. I mean when you want to simulate a series of discrete events(e.g. Poisson dist.), its name becomes Poisson process. Here, the timing of events is random, but your model is still Poisson. Hence, you could use that code.
Zeynep Toprak
Zeynep Toprak 2020 年 5 月 31 日
perfect! I'm confusing them most of time. I see now. Many thanks :)

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

その他の回答 (3 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2020 年 5 月 14 日
Here is the alternative solution:
T = 1;
lambda = 12;
t = linspace(0, T, 500);
k=randi([1,10], 500);
f = (lambda.^k) .* exp(-lambda) ./ factorial(k);
N = sum(f);
disp(N);
stairs(t,N)
Good luck
  2 件のコメント
Zeynep Toprak
Zeynep Toprak 2020 年 5 月 14 日
Thank you very much for your help. Is this my second code is true to simulate poisson process? I thought it was trivial, but you confirm it right? and how can I do this the same thing by using poissrnd() ?
Zeynep Toprak
Zeynep Toprak 2020 年 5 月 14 日
And also, it must be N(0) = 0 by the definition of poisson process (Poisson process defintion link), but here, it is not zero.

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


Sulaymon Eshkabilov
Sulaymon Eshkabilov 2020 年 5 月 14 日
Why not to use MATLAB's built in fcn: poissrnd()
  3 件のコメント
Sa'adatu Abubakar
Sa'adatu Abubakar 2021 年 7 月 29 日
Hello I'm also interested in the area please can you help me with the MATLAB code for poison arrival and general servive with single server?. Thank you
Sa'adatu Abubakar
Sa'adatu Abubakar 2021 年 7 月 29 日
please I mean poisson arrival with general service and single server.

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


Najme Benvari
Najme Benvari 2023 年 5 月 23 日
Hi I read the Poisson production code when the jump size is random and the intensity of the jumps is Stochastic and a CIR process. I will be very thankful.
  1 件のコメント
Najme Benvari
Najme Benvari 2023 年 5 月 25 日
?

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

Community Treasure Hunt

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

Start Hunting!

Translated by