/////// Exercice 1 // Question 1 n=200; x=grand(n,1,"nor",0,1); y=grand(n,1,"nor",0,1); correl(x,y,eye(n,n)) // Question 2 a=0.2 u=a*x+sqrt(1-a**2)*y; mean(u) variance(u) clf();histplot(20,u,normalization=%t); absc=linspace(-10,10,100); plot(absc,exp(-(absc)^2/2)/sqrt(2*%pi)); // Question 3 covar(x,u,eye(n,n)) correl(x,u,eye(n,n)) // Question 4 clf();plot(x,u,'p',-3:3,-3:3); for a2 = -100:100 a=a2/100; u=a*x+sqrt(1-a**2)*y; clf(); plot([-3,3],[0,0]) plot([0,0],[-3,3]) plot(x,u,'p'); end // Question 5 v=x^2; // Questions 6 et 7 clf(); histplot(20,v,normalization=%t) absc=linspace(0.01,10,100); plot(absc,exp(-absc/2)./(sqrt(2)*gamma(0.5)*sqrt(absc))) // Questions 8 et 9 clf(); absc=linspace(-4,4,100); plot(absc,exp(-(absc)^2/2)/sqrt(2*%pi)) k=1 ord=gamma((k+1)/2)/(gamma(k/2)*sqrt(k*%pi))*((1+absc.^2/k).^(-(k+1)/2)); plot(absc,ord,'r') k=10 ord=gamma((k+1)/2)/(gamma(k/2)*sqrt(k*%pi))*((1+absc.^2/k).^(-(k+1)/2)); plot(absc,ord,'g') k=100 ord=gamma((k+1)/2)/(gamma(k/2)*sqrt(k*%pi))*((1+absc.^2/k).^(-(k+1)/2)); plot(absc,ord,'m') /////// Exercice 2 // Question 1 x=[3.41 2.85 7.57 9.73 10.19 4.58 2.62 5.90 4.57 4.52]; sigma=2; n=length(x) // Question 2 3+sigma*cdfnor("X",0,1,0.95,0.05)/sqrt(n) // Question 3 mean(x) // Question 4 [P,Q]=cdfnor("PQ",mean(x),3,sigma/sqrt(n)) // Question 5 n=1000 x=grand(n,1,"nor",4.5,sigma); 3+sigma*cdfnor("X",0,1,0.95,0.05)/sqrt(n) mean(x) [P,Q]=cdfnor("PQ",mean(x),3,sigma/sqrt(n)) // Question 6 n=1000 x=grand(n,1,"nor",2.8,sigma); 3+sigma*cdfnor("X",0,1,0.95,0.05)/sqrt(n) mean(x) [P,Q]=cdfnor("PQ",mean(x),3,sigma/sqrt(n)) // Question 7 N=1000 n=100 resultats=zeros(N,1); for i=1:N x=grand(n,1,"nor",3,sigma); resultats(i)=mean(x); end // Question 8 clf(); histplot(20,resultats,renormalization=%f) plot([cdfnor("X",3,sigma/sqrt(n),0.95,0.05),cdfnor("X",3,sigma/sqrt(n),0.95,0.05)],[0,2.5]) // Question 9 sum(resultats>cdfnor("X",3,sigma/sqrt(n),0.95,0.05))/N // Question 10 N=1000 n=100 resultats=zeros(N,1); for i=1:N x=grand(n,1,"nor",4,sigma); resultats(i)=mean(x); end clf(); histplot(20,resultats,renormalization=%f) plot([cdfnor("X",3,sigma/sqrt(n),0.95,0.05),cdfnor("X",3,sigma/sqrt(n),0.95,0.05)],[0,2.5]) sum(resultats>cdfnor("X",3,sigma/sqrt(n),0.95,0.05))/N