% LMFig040302_4th.m
% Larsen & Marx Figure 4.3.2 plot, page 295
% Use LMex040308_4th.m as a model
% Larsen & Marx (2006) Introduction to Mathematical Statistics, 4th edition
% Page 267
% Standard normal distribution using ezplot
% Integration using the symbolic math toolbox
% Written by Eugene.Gallagher@umb.edu
% October 1, 2010, revised: 1/10/11

hold off; clf
syms z
% Just for fun, use symbolic math integration to find the integral
INTP=eval(int(1/sqrt(2*pi)*exp(-(z^2/2)),-inf,1.14))
% or use the standard normal cumulative distribution function:
intp=normcdf(1.14)
 
% Plot Figure 4.3.2
mu=0;
sigma=1;
X=-3.5:0.1:3.5;
Y = normpdf(X,mu,sigma);
plot(X,Y,'--r');
axis([-3.55 3.55 0 0.41]);
title('Figure 4.3.2','FontSize',20);
ax1=gca;
xlabel('Z','FontSize',16),
ylabel('f_z(z)','FontSize',16);
ax1=gca;
set(ax1,'XTick',[-3 -2 -1 0 1.14 2 3] ,'FontSize',14,...
    'XTickLabel',{'-3','-2','-1','0','1.14','2','3'},'FontSize',14)
set(ax1,'ytick',0:.1:0.4,'FontSize',14)
hold on;
xf=-3.5:.01:1.14;yf=normpdf(xf,mu,sigma);
fill([-3.5 xf 1.14]',[0 yf 0]',[.8 .8 1])
text(1.4,0.25,'Area = 0.8729','FontSize',18)
figure(gcf);pause
hold off;