function IEOR161HW8

function IEOR161HW8 - function IEOR161HW8() clear all close...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
function IEOR161HW8() clear all close all clc %% Simulation part (C) %initialize for the Markov Chain n1=0; n2=0; l=1; m1=2; m2=3; N=20000; %initialize for the geometric limitiing distribution p1=1-l/m1; p2=1-l/m2; %form tracking vars t=[5,10,50,100,200]; x1 = zeros(length(t),N); x2 = zeros(length(t),N); geo1 = zeros(1,N); geo2 =zeros(1,N); for i = 1:length(t); for j = 1:N; n1=0; n2=0; wait1=0; wait2=0; r1 = rand; while r1>p1; wait1=wait1+1; r1=rand; end r2 = rand; while r2>p2; wait2=wait2+1; r2=rand; end for k = 1:t(i); if n1==0 & n2==0; n1=n1+1; elseif n1>=1 & n2==0; p=rand; n1=n1+(p<(l/(l+m1)))-(p>(l/(l+m1))); n2=n2+(p>(l/(l+m1))); elseif n1==0 & n2>=1; p=rand; n1=n1+(p<(l/(l+m2))); n2=n2-(p>(l/(l+m2))); elseif n1>=1 & n2>=1; p=rand; n1=n1+(p<(l/(l+m1+m2)))-(p<(1-m2/(l+m1+m2))& p>(l/(l+m1+m2))); n2=n2 - (p>(1-m2/(l+m1+m2))) + (p<(1-m2/(l+m1+m2))& p>(l/(l+m1+m2))); end end geo1(j)=wait1; geo2(j)=wait2; x1(i,j)= n1;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
x2(i,j)= n2; end figure(t(i)); hist(x1(i,:),40); figure(t(i)+1);
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/17/2011 for the course IEOR 161 taught by Professor Lim during the Spring '08 term at Berkeley.

Page1 / 3

function IEOR161HW8 - function IEOR161HW8() clear all close...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online