function [d,ps]=GG1(n,lambda,mu,sigma,rstate) %Simulate delays in queue for queuing model (GI/G/1) %Arrivals exponential, service normally distributed. % %n the number of customers %lambda the arrival rate of customers %mu mean service time of customers %sigma standard deviation of the service time %rstate state of random numbr generator ua=rstate; %Random stream for arrivals ud=rstate+2*n; %Random stream for service delays t=0; %Simulation clock rand('state',ua); %The time of next customer arrival ta=exprnd(lambda); td=inf; %The time of next departure ps=zeros(1,n); %Waiting delay perturbations of customers queue=[]; %Queued customers n_in=0; %Number of customer arrivals n_out=0; %Number of customer departures d=zeros(1,n); %Service delays %The main simulation loop while n_out