function [at,tsb,tse,numsyst]=mg1queue(miat,ncust)
% see banks page , miat=mean interarrival time, 
% ncust=number of customers.
% define a function rservice   which generates random service times

% initialize variables assuming queue empty at time 0
% arrival times of customers
at=zeros(1,ncust);
time service begins
tsb=zeros(1,ncust);
% time service ends
tse=zeros(1,ncust);
numsyst=zeros(1,ncust);
% numsyst is the number in syst immediately BEFORE the arrival
at(1)=exprnd(1,1,miat);
tsb(1)=at(1);
tse(1)=at(1)+rservice
for i=2:ncust
 at(i)=at(i-1)+exprnd(1,1,miat);
 tsb(i)=max(at(i),tse(i-1));
 tse(i)=tsb(i)+rservice;
 numsyst(i)=i-1-sum(tse<=at(i));
end






