// Exercice 2

U1=rand(1,1000);
U2=rand(1,1000);
U3=rand(1,1000);
V1=2*U1-1;
V2=2*U2-1;
S=V1.^2+V2.^2;
X=sqrt(-2*log(U3)).*V1./sqrt(S);
Y=sqrt(-2*log(U3)).*V2./sqrt(S);
plot2d(X,Y,-1)
figure 
histplot(20,X) // histogramme de X
t1=[-3:0.1:3];
plot2d(t1,dnorm(t1),2) // densitÃ© normale
XX=-gsort(-X) // rangement par ordre croissant
n=length(XX)
figure 
plot2d(XX,[1:n]/n) // fonction de rÃ©partition empirique
t2=[-3:0.1:3];
plot2d(t2,pnorm(t2),2)