somebody please help me with this code

1 次查看(过去 30 天)
function s=poissonarrivals(lam,T)
%arrival times s=[s(1) ... s(n)]
% s(n)<= T < s(n+1)
n=ceil(1.1*lam*T);
s=cumsum(exponentialrv(lam,n));
while (s(length(s))< T),
s_new=s(length(s))+ ...
cumsum(exponentialrv(lam,n));
s=[s; s_new];
end
s=s(s<=T);
function N=poissonprocess(lambda,t)
%N(i) = no. of arrivals by t(i)
s=poissonarrivals(lambda,max(t));
N=count(s,t);
hi trying to understand how this code works but have no clue... its a solution for the question below
Generate a sample path of N(t), a rate = 5 arrivals/min Poisson process. Plot N(t)
over a 10-minute interval.
i really dont understand how this works and like there are commands like exponentialrv which i cant find
  1 个评论
Geoff Hayes
Geoff Hayes 2021-5-21
Where did you get the above code? Is it something that you have written or are expected to write as part of the homework? The code from https://www.mathworks.com/matlabcentral/answers/444462-small-store-parking-stochastic-process is similar to what you have above - is that where you copied it from?

请先登录,再进行评论。

回答(1 个)

Nagasai Bharat
Nagasai Bharat 2021-5-24
Hi,
From my understanding you are trying to generate a Poisson process with a given interval and arrival rate. To do that the following documentation would help you.
From the above code, the exponentialrv looks like a user defined function and is not a MATLAB command or function as per this.

Community Treasure Hunt

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

Start Hunting!

Translated by