Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Project 4

clear all
sample_num = 50000;
mean_one = 25;
std_one = 25;
n = 12;
lam = 1/mean_one;
x = -log(rand(1,sample_num))/lam;
0.04

zi=500000;
z=1:500000;
for i=1:1:zi
z(i)=0;
end

0.035

j = 0;

0.025

mean=299.9322 std=86.5735 prob=0.21264

0.03

for i=1:1:zi
y = -log(rand(1,12))/lam;
sum_y = sum(y);
z(i)=sum_y;
if (sum_y > 365)
j = j+1;
end
end

0.02
0.015
0.01
0.005
0
-100

prob = j / zi;
std_z = std(z);
mean_z = mean(z);

100

200

300

bin_sizez = .01*(2.5/lam)*12;
binsz =[0:bin_sizez:(2.5/lam)*12];
v = hist(z,binsz);
v1 =v/zi;
bar(binsz,v1)
legend(['mean=',num2str(mean_z), '
prob=',num2str(prob)]);

std=', num2str(std_z), '

= 25
= *

=25 days
=

= 12 * 25 = 300

= .755
= 86

400

500

600

700

800

You might also like