somebody please help me with this code

1 view (last 30 days)
지우 김
지우 김 on 20 May 2021
Answered: Nagasai Bharat on 24 May 2021
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 Comment
Geoff Hayes
Geoff Hayes on 21 May 2021
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?

Sign in to comment.

Answers (1)

Nagasai Bharat
Nagasai Bharat on 24 May 2021
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!