{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw1_2_8_a

# hw1_2_8_a - clear all clc close all b=1 n=1000 for...

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

clear all; clc; close all; b=1; n=1000; for j=1:10000 a=rand(1,n); x(j)=(b/n)*sum(a-0.5); end [e,r]=hist(x,100); plot(r,e); vr_b=(b^2)/(12*n); x1=-0.04:0.0001:0.04; t=5*((1/sqrt(2*pi*vr_b))*exp(-(x1.^2/(2*vr_b)))); hold plot(x1,t,'r'); p legend(' x','Gaussian RV'); figurea subplot (1,2,1); plot(r,e); for j=1:10000 a=rand(1,n); y(j)=(b/n)*sum(a-0.5); end e subplot (1,2,2); [e,r]=hist(y,100); plot(r,e); for j=1:10000 z(j)=sqrt((x(j)^2)+(y(j)^2)); end figure; [e,r]=hist(z,100); plot(r,e); %% Rayleigh using uniformly distributed RV b=3; n=10000; a=rand(1,n); vr_r=var(x); a=rand(1,n); for j=1:n y1(j)=sqrt(-(2*vr_r*log(a(j)))); end figure; [e,r]=hist(y1,100); plot(r,e); p %% effect of method (a) as n varies clear all; clc; % close all; b=3; n=[10,100,1000,10000]; for i=1:length(n) for j=1:10000 ax=rand(1,n(i));

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

View Full Document
x(j)=(b/n(i))*sum(ax-0.5); ay=rand(1,n(i)); y(j)=(b/n(i))*sum(ay-0.5); z(j,i)=sqrt((x(j)^2)+(y(j)^2)); end e [e(i,:),r(i,:)]=hist(z(:,i),100); % figure % hist(z(:,i),500); end figure; hold; plot(r(1,:),e(1,:),'r'); plot(r(2,:),e(2,:),'g'); plot(r(3,:),e(3,:),'b'); plot(r(4,:),e(4,:),'k');
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern