1 / 30

CEE162/262c Lecture 14: Continuous Stochasticity

CEE162/262c Lecture 14: Continuous Stochasticity. figure(2) plot(t,N(:,1:100), 'k.-' ); xlabel( 't' ); ylabel( 'N(t)' ); figure(3) plot(t,exp(-lambda*t), 'r-' , ... t,lambda*t.*exp(-lambda*t), 'g-' , ... t,(lambda*t).^2/2.*exp(-lambda*t), 'b-' , ... t,num(1:3,:), 'k.' );

fraley
Download Presentation

CEE162/262c Lecture 14: Continuous Stochasticity

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CEE162/262c Lecture 14: Continuous Stochasticity CEE162/262c Lecture 14: Continuous stochasticity

  2. CEE162/262c Lecture 14: Continuous stochasticity

  3. CEE162/262c Lecture 14: Continuous stochasticity

  4. CEE162/262c Lecture 14: Continuous stochasticity

  5. CEE162/262c Lecture 14: Continuous stochasticity

  6. CEE162/262c Lecture 14: Continuous stochasticity

  7. CEE162/262c Lecture 14: Continuous stochasticity

  8. CEE162/262c Lecture 14: Continuous stochasticity

  9. CEE162/262c Lecture 14: Continuous stochasticity

  10. CEE162/262c Lecture 14: Continuous stochasticity

  11. CEE162/262c Lecture 14: Continuous stochasticity

  12. CEE162/262c Lecture 14: Continuous stochasticity

  13. CEE162/262c Lecture 14: Continuous stochasticity

  14. CEE162/262c Lecture 14: Continuous stochasticity

  15. CEE162/262c Lecture 14: Continuous stochasticity

  16. CEE162/262c Lecture 14: Continuous stochasticity

  17. CEE162/262c Lecture 14: Continuous stochasticity

  18. CEE162/262c Lecture 14: Continuous stochasticity

  19. CEE162/262c Lecture 14: Continuous stochasticity

  20. CEE162/262c Lecture 14: Continuous stochasticity

  21. CEE162/262c Lecture 14: Continuous stochasticity

  22. CEE162/262c Lecture 14: Continuous stochasticity

  23. CEE162/262c Lecture 14: Continuous stochasticity

  24. figure(2) plot(t,N(:,1:100),'k.-'); xlabel('t'); ylabel('N(t)'); figure(3) plot(t,exp(-lambda*t),'r-',... t,lambda*t.*exp(-lambda*t),'g-',... t,(lambda*t).^2/2.*exp(-lambda*t),'b-',... t,num(1:3,:),'k.'); legend('n=0','n=1','n=2',1); xlabel('t'); ylabel('P_n(t)'); figure(4) plot([0:Nmax],num(:,nsteps/4),'r-',... [0:Nmax],num(:,nsteps/2),'g-',... [0:Nmax],num(:,3*nsteps/4),'b-',... [0:Nmax],num(:,nsteps),'m-'); legend('T/4','T/2','3T/4','T'); xlabel('N'); ylabel('p(N,t)'); figure(5); Nbar = mean(N,2); plot(t,Nbar,'k-'); xlabel('t'); ylabel('mean(N(t))'); % File: unserved.m lambda = .1; % Arrival rate T = 80; nsteps = 400; dt = T/nsteps; numtrials = 10000; N = zeros(nsteps,numtrials); grow = rand(nsteps,numtrials)<lambda*dt; N = cumsum(grow); Nmax = max(max(N)); [num,x] = hist(N',[0:Nmax]); num = num/numtrials; t = [dt:dt:dt*nsteps]; [T,X] = meshgrid(t,x); figure(1) mesh(T(:,1:10:end),X(:,1:10:end),num(:,1:10:end)); xlabel('t'); ylabel('N'); zlabel('p(N,t)'); CEE162/262c Lecture 14: Continuous stochasticity

  25. Figure 1 CEE162/262c Lecture 14: Continuous stochasticity

  26. Fig. 3 Fig. 2 Fig. 5 Fig. 4 CEE162/262c Lecture 14: Continuous stochasticity

  27. Nmax = max(max(N)); [num,x] = hist(N',[0:Nmax]); num = num/numtrials; t = [dt:dt:dt*nsteps]; figure(1) plot(t,N(:,1:10),'k-'); xlabel('t'); ylabel('N(t)'); figure(2) onest = ones(size(t)); plot(t,(1-rho)*onest,'r-',... t,rho*(1-rho)*onest,'g-',... t,rho^2*(1-rho)*onest,'b-',... t,num(1:3,:),'k.'); legend('n=0','n=1','n=2',1); xlabel('t'); ylabel('P_n(t)'); % File: singleserverqueue.m Ns=2; % Steady-state # of customers in line rho = Ns/(1+Ns);% Traffic intensity lambda = .1; % Arrival rate mu = lambda/rho;% Service rate T = 1000; nsteps = 4000; dt = T/nsteps; numtrials = 4000; N = zeros(nsteps,numtrials); for trial=1:numtrials fprintf('Trial %d of %d\n',trial,numtrials); for n=2:nsteps P=rand<(lambda*dt); Q=rand<(mu*dt); if(P==1 & Q==1) r=rand; P=P*(r<0.5); Q=Q*(r>=0.5); end N(n,trial)=N(n-1,trial)+P-(Q & N(n-1,trial)>0); end end CEE162/262c Lecture 14: Continuous stochasticity

  28. % Compute the power series to get the second moment of N % First moment is known analytically E1 = rho/(1-rho); % Second moment is compute numerically n = [0:100]; E2 = sum(n.^2.*rho.^n*(1-rho)); sig = sqrt(E2-E1^2); figure(3); Nbar = mean(N,2)'; Nstd = std(N')'; Nmean = rho/(1-rho); plot(t,Nbar,'k-',... t,Nstd,'r-',... [0 max(t)],[E1 E1],'k--',... [0 max(t)],[sig sig],'r--'); legend('Mean','Std',4);xlabel('t');ylabel('mean(N(t))'); CEE162/262c Lecture 14: Continuous stochasticity

  29. Fig. 1 Fig. 3 Fig. 2 CEE162/262c Lecture 14: Continuous stochasticity

  30. CEE162/262c Lecture 14: Continuous stochasticity

More Related