clear X=[46 37 39 48 47 44 35 31 44 37]; Y=[35 33 31 34 34 30 27 32 31 31]; n1=length(X); n2=length(Y); alpha=0.05; # significance level #The null hypothesis is: H0: vx!=vy (the standard is meet) (the variances differ) #The alternative hypothesis is: H1: vx=vy (the standard is not meet) (the variances are the same) #Both tail test when sigma is unknown [H, PVAL, CI, STATS] = vartest2(X,Y,'alpha',alpha,'tail','both'); if H==1 printf("The null hypothesis is rejected\n\n"); printf("The data suggests that the standard is not meet\n\n"); printf("The variances seem to be the same"); else printf("The null hypothesis is not rejected\n\n"); printf("The data suggests that the standard is meet\n\n"); printf("The variances seem to differ\n\n"); endif z_alpha = norminv(alpha/2, 0, 1); # calculating tt of alpha/2 RR = [-inf z_alpha]; # first part of the regection region z_alpha2 = norminv(1-alpha/2, 0, 1); # calculating tt of 1-alpha/2 RR2 = [z_alpha2 +inf]; # second part of the regection region printf("The regection region is: (%4.3f, %4.3f) reunited with (%4.3f, %4.3f)\n",RR,RR2); printf("The observed value of the test statistic is: %4.3f\n", STATS.fstat ); printf("The Pvalue of the test is: %4.3f\n\n",PVAL); oneminualpha=0.95; # confidence level a1= (mean(X) - mean(Y) - tinv(1-alpha/2,n1+n2-2)*sqrt(((n1-1)*var(X)+(n2-2)*var(Y))/(n1+n2-2))*sqrt(1/n1+1/n2)); a2=(mean(X) - mean(Y) + tinv(1-alpha/2,n1+n2-2)*sqrt(((n1-1)*var(X)+(n2-2)*var(Y))/(n1+n2-2))*sqrt(1/n1+1/n2)); printf("The Confidence interval between population means when sigma1=sigma2, where sigma and sigma2 are unknown, is (%4.3f, %4.3f)\n", a1,a2);