% LMFig060205_4th.m
% Larsen & Marx (2001, p. 367).
% Introduction to Mathematical Statistics, 4th edition
% Normal probability pdf
% Written by Eugene.Gallagher@umb.edu
% written for EEOS601
z025=norminv(0.025);
z975=norminv(0.975);
z=-3.05:.001:3.05;
fzz=normpdf(z);
plot(z,fzz,'linestyle','--','color','r','linewidth',3)
ylabel('f_z(z)','FontSize',20)
xlabel('z','FontSize',22)
axis([-3.05 3.05 0 0.405])
set(gca,'Ytick',[-1.96 0 0.6 1.96],'FontSize',18)
set(gca,'Xtick',[-1.96 0 0.60 1.96],...
    'XtickLabel',{'-1.96', '0','z=0.60','1.96'},'FontSize',18)
ax=axis;
ax1=gca; % save the handle of the graph
title('Figure 6.2.5','FontSize',22)
hold on
fz=normpdf([z025 z975]);
plot([z025 z025;z975 z975]',[0 fz(1);0 fz(2)]','-k','linewidth',1) 
% Fill in the upper tail with fill
y2=z975:.001:ax(2);
fy2=normpdf(y2);
fymax=normpdf(ax(2));
fill([z975 y2 ax(2) ax(2)],[0 fy2 fymax 0],[.8 .8 1])
% Fill in the lower tail with fill
y3=ax(1):.001:z025;
fy3=normpdf(y3);
fymin=normpdf(ax(1));
fill([ax(1) ax(1) y3 z025],[0 fymin fy3 0],[.8 .8 1])
t=sprintf('Area=0.025');
text(ax(1)+.3,.2,t,'Color','b','FontSize',20);
text(1.6,.2,t,'Color','b','FontSize',20);
figure(gcf)
hold off