% LMFig060404_4th.m
% Using as a model %LMcs030201_4th.m, page 450 in
% Larsen & Marx (2006) Introduction to Mathematical Statistics, 4th edition
% Written 3/10/11 (35 min)
% Eugene.Gallagher@umb.edu for EEOS601 UMASS/Boston
CritVal=norminv(.95,25,2.4/sqrt(30));
xmin=25;xmax=27.1;
X=xmin:0.005:xmax;
sigmaj=2.4;n=30;
Power=1-normcdf(CritVal,X,sigmaj/sqrt(n));
x=[25.75 26.8]; Pow=1-normcdf(CritVal,x,sigmaj/sqrt(n));
plot(X,Power,':k','LineWidth',3)
axis([xmin xmax 0 1.15])
hold on
set(gca,'Xtick',[25 25.5 x(1) 26 26.5 x(2) 27],'Ytick',[0:.25:1],'FontSize',18)
% This plots horizontal and vertical lines on the graph
plot([x(1) x(1);xmin x(1);x(2) x(2);xmin x(2)]',[0 Pow(1);...
    Pow(1) Pow(1);0 Pow(2);Pow(2) Pow(2)]','--m','LineWidth',3);
ylabel ('Power = 1 - \beta','FontSize',20);
xlabel('Presumed value for \mu','FontSize',20)
title('Figure 6.4.4','FontSize',22)
t1=sprintf('Power = %6.4f',Pow(1));
t2=sprintf('Power = %6.4f',Pow(2));
text(xmin+0.1,0.57,t1,'FontSize',18);
text(xmin+0.1,1.04,t2,'FontSize',18);
figure(gcf)
pause
hold off