This preview shows pages 1–6. Sign up to view the full content.

STA5107: Dr. Srivastava Homework 1 Jaime Frade 1. OUTPUT

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

View Full Document
STA5107: Dr. Srivastava Homework 1 Jaime Frade CODE %prob1 clear all T_1 = [1, 0.1, 0.01, 0.001]; n1=size(T_1); for j=1:4; alpha_1 = 1.0; T = T_1(j); s_1 = sqrt(T)*alpha_1; n=10/T; t_1 = (0:s_1:n*s_1); random_u = random( 'uniform' ,0,1,1,n+1); score = zeros(1,n+1); for k=1:n+1; if random_u(k) <=0.5; score(k) = -1; else score(k) = 1; end ; end ; sum_1 = score(1,n+1); for m=2:n+1; sum_1(m) = sum(score(1:m))*s_1; end ; figure(j); stairs(t_1,sum_1); xlabel( 'time' ) ylabel( 'x_t' ) title([ 'Total ' int2str(n) ' Step random walk' ]); hold off ; saveas(figure(j),[ 'Total Step random walk ' int2str(n) '.png' ]) end ; 2. OUTPUT
STA5107: Dr. Srivastava Homework 1 Jaime Frade CODE %prob1

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

View Full Document
STA5107: Dr. Srivastava Homework 1 Jaime Frade clear all %prob2 for n=1:5 hold on function1; end ; function y=function1 intensity=.1; time(1)=0; i=2;

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: while intensity>0 n_1(i-1)=(-1/intensity)*log(rand); time(i)=n_1(i-1)+time(i-1); if time(i)<=100 i=i+1; else break end end for n=1:i-1 f_1(n)=time(n); end n=[0:1:i-2]; figure(1); stairs(f_1,n); xlabel( 'time' ) ylabel( 'count' ) saveas(figure(1),[ 'HW1 prob 2.png' ]) 3. OUTPUT STA5107: Dr. Srivastava Homework 1 Jaime Frade CODE %prob3 STA5107: Dr. Srivastava Homework 1 Jaime Frade intensity = 0.1; for i=1:1000; u_1 = random( 'uniform' ,0,1,i); d_1 =-log(u_1)/intensity; time1 = zeros(1,i); for j=2:i; time1(j) = time1(j-1) + d_1(j-1); end ; sum_1=0; for k=1:i; if time1(k)>=10 && time1(k)<=20; sum_1=sum_1 + 1; else sum_1 = sum_1; end ; end ; ht(i) = sum_1; end ; figure(1) hist(ht); saveas(figure(1),[ 'HW1 prob 3.png' ])...
View Full Document