function IEOR161HW6 - end %% histograms: part d -...

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

View Full Document Right Arrow Icon
function IEOR161HW6() clc %% histograms: part(a) for N1(T) total = zeros(1,10000); T = 10; p = .5; for i = 1:10000; clk = 0; count = 0; while clk < T; interarrivals = -1/2*log(1-rand); clk = clk + interarrivals; count = count + (rand<p); end total(i) = count; end figure(1) hist(total,100); mean_N1 = mean(total); sd_N1 = std(total); fprintf( 'Stats for N1:\n mean: %f \n sd: %f \n\n' ,mean_N1,sd_N1) %% histograms: part(b) for N2(T) total = zeros(1,10000); T = 10; p = .5; for j = 1:3; N1 = 2+j*4; for i = 1:10000; clk = 0; count = 0; while clk < T; interarrivals = -1/2*log(1-rand); clk = clk + interarrivals; count = count + (rand>p); end total(i) = count; end figure(j+1) hist(total,100); mean_N2 = mean(total); sd_N2 = std(total); fprintf( 'Stats for N2|N1 = %g \n mean: %f \n sd: %f\n\n' ,N1, mean_N2, sd_N2)
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: end %% histograms: part d - dependence total1 = zeros(1,10000); total2 = zeros(1,10000); T = 10; for i = 1:10000; clk = 0; count1 = 0; count2 = 0; r= 2; p = .5; while clk &lt; T; interarrivals = -1/r*log(1-rand); type = rand; if type&lt;p; r = .95*r; p = 1.02*p; count1 = count1 + 1; elseif type&gt;p; r = 1.02*r; p = .98*p; count2 = count2 + 1; end clk = clk + interarrivals; end total1(i) = count1; total2(i) = count2; end figure(5) hist(total1,100); figure(6) hist(total2,100); mean_N1 = mean(total1); mean_N2 = mean(total2); sd_N1 = std(total1); sd_N2 = std(total2); fprintf( 'Stats for N1:\n mean: %f \n sd: %f \n\n' ,mean_N1,sd_N1) fprintf( 'Stats for N2:\n mean: %f \n sd: %f \n' ,mean_N2, sd_N2) end...
View Full Document

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

Page1 / 2

function IEOR161HW6 - end %% histograms: part d -...

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

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