You are on page 1of 2

6.

85
Problem b.
>> U1=rand(1000,1);
U2=rand(1000,1);
R2=-1*log(U1);
TH=2*pi*U2;
X1=sqrt(R2).*sin(TH);
X2=sqrt(R2).*cos(TH);
Y1=X1+sqrt(2)*X2;
Y2=-X1+sqrt(2)*X2;
plot(Y1,Y2,'+')

Plot:

The shape is of ellipse which proves the matrix is right.

7.
>> U1=rand(5000,1);
U2=rand(5000,1);
R2=-1*log(U1);
TH=2*pi*U2;
X1=sqrt(R2).*sin(TH);
X2=sqrt(R2).*cos(TH);
Y1=X1+sqrt(2)*X2;
Y2=-X1+sqrt(2)*X2;
plot(Y1,Y2,'+')
Plot:

You might also like