{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Numerical_Results_of_the_Programs

# Numerical_Results_of_the_Programs - S=S 1 end end...

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

Numerical Results of the Programs 1. % Run the function CovUniExpo to extimate the covariance with different size of samples CovUniExpo(100); Cov(U,e^U)=0.1508109 by 100 samples CovUniExpo(1000); Cov(U,e^U)=0.1441544 by 1000 samples CovUniExpo(10000); Cov(U,e^U)=0.1390912 by 10000 samples 2. a) Estimate E[N] by generate 5000 smaples of N S=0; for i=1:5000 S=S+N_generator(); end fprintf('E[N]=%9.7f\n',S/5000); E[N]=2.9976000 b) Estimate P(N=i) by generate 5000 samples of N P=[0,0,0,0,0,0,0]; for i=1:5000 k=N_generator(); if(k<7) P(1,k+1)=P(1,k+1)+1; end end for j=1:7 fprintf('P(N=%d)=%9.7f\n',j-1,P(1,j)/5000) end P(N=0)=0.0464000 P(N=1)=0.1566000 P(N=2)=0.2174000 P(N=3)=0.2180000 P(N=4)=0.1714000 P(N=5)=0.1022000 P(N=6)=0.0546000 3.

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

View Full Document
Test if the program is correct P=[0.5,0.5]; S=0; for i=1:1000 if(Disc_RV_generator(P)==1)
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: S=S+1; end end fprintf('P(X=1)=%9.7f, the error is %9.7f',S/1000,S/1000-0.5); P(X=1)=0.5060000, the error is 0.0060000 Test the robustness of the program P=[0.6,0.5]; Disc_RV_generator(P); error! P is not a pmf. Test the robustness of the program P=[-1,1]; Disc_RV_generator(P); error! P is not a pmf. 4. % Estimate the expected number of hits by generating 1000 samples S=0; for i=1:1000 S=S+Hit_generator(); end fprintf('E[Number of hits]=%9.7f', S/1000) E[Number of hits]=1.0030000 5. % Estimate the expected number of dice rolls needed by generating 1000 % samples S=0; for i=1:1000 S=S+Roll_generator(); end fprintf('E[Number of dice rolls needed]=%9.7f\n',S/1000); E[Number of dice rolls needed]=61.7660000...
View Full Document

{[ snackBarMessage ]}

### Page1 / 3

Numerical_Results_of_the_Programs - S=S 1 end end...

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

View Full Document
Ask a homework question - tutors are online