N=1000;

//Ex 1,3
b=0;
while (b==0)
    u=grand(1,1,'unf',0,1);
    x=1/(1-u);
    if (u<exp(1-x)) then
        b=1;
    end,
end,
//disp(x);

//Ex 2, 2
tab=[];
for i=1:N
    v=grand(1,1,'nor',0,1);
    tab=[tab,sqrt(abs(v))];
end,
disp("Moyenne");
disp(mean(tab));
disp("Variance");
disp(variance(tab));

//Ex 2, 3


tab=[];
for i=1:N
    v=grand(1,1,'nor',0,1);
    tab=[tab,sqrt(abs(v))-abs(v)];
end,
disp("Moyenne");
disp(mean(tab)+sqrt(2/%pi));
disp("Variance");
disp(variance(tab));
    

