close all clear all r=0.01; r2=1-r/2; mu=0.574; v=0.008^2; n=6; n1=n-1; ho_min=mu-sqrt(v)*tinv(r2,n1)/sqrt(n1); ho_max=mu+sqrt(v)*tinv(r2,n1)/sqrt(n1); figure('PaperUnits','normalized', 'PaperPosition',[ 0 0 1 1 ]) %,'visible','off') x=[-5:0.001:5]; subplot(2,1,1) area(x,tpdf(x,n1),'linewidth',2,'FaceColor',[0.9 0.2 0]) set(gca,'plotboxaspectratio',[1.5 1 1],'fontsize',20,'linewidth',2) title('PDF de la loi de Student','fontsize',20) xlabel('x','fontsize',20) ylabel('P(x)','fontsize',20) subplot(2,1,2) area(x,tcdf(x,n1),'linewidth',2,'FaceColor',[0.9 0.9 0]) set(gca,'plotboxaspectratio',[1.5 1 1],'fontsize',20,'linewidth',2) title('CDF de la loi de Student','fontsize',20) xlabel('x','fontsize',20) ylabel('C(x)','fontsize',20) fprintf('============================\n'); fprintf('L hypothese principale Ho :\n'); fprintf(' La machine outil produit des boulons de 0.574 g en moyenne.\n'); fprintf('L hypothese alternative H1 :\n'); fprintf(' La machine outil produit des boulons qui sont en moyenne plus ou moins lourds que 0.574 g.\n'); fprintf('============================\n'); fprintf('Le test:\n'); fprintf('La machine outil fonctionne bien si la masse moyenne de l echantillon est \n'); fprintf(' %8.5f < masse moyenne < %8.5f \n\n',ho_min,ho_max); fprintf('L hypothese alternative H1 :\n'); fprintf('La machine outil ne fonctionne plus correctement si \n'); fprintf(' masse moyenne > %8.5f \n',ho_max); fprintf(' masse moyenne < %8.5f \n',ho_min); fprintf('============================\n'); fprintf('============================\n'); fprintf('============================\n'); k=0; for i=0.530:0.0005:0.6200 error_sup=1-tcdf((ho_max-i)/(sqrt(v)/sqrt(n1)),n1); error_inf=tcdf((ho_min-i)/(sqrt(v)/sqrt(n1)),n1); k=k+1; beta_mu(k,1)=i; beta_mu(k,2)=error_sup+error_inf; end figure('PaperUnits','normalized', 'PaperPosition',[ 0 0 1 1 ]) %,'visible','off') area(beta_mu(:,1),beta_mu(:,2),'linewidth',2,'FaceColor',[0.2 0.9 0]) set(gca,'plotboxaspectratio',[1.5 1 1],'fontsize',20,'linewidth',2) title('Courbe de Puissance de Test','fontsize',20) xlabel('\mu^d','fontsize',20) ylabel('1-\beta','fontsize',20) print -depsc puis.eps