% LMFig070302_4th.m
% Page 427 in Larsen & Marx, 2nd ed, page 479 in 4th edition
% Larsen & Marx (2006) Introduction to Mathematical Statistics, 4th edition
% Pots of the z & t distribution.
% E. Gallagher, Eugene.Gallagher@umb.edu
% Revised: 2/5/04
% Plot the normal probability pdf:
% The normal probability equation is provided on p. 264 & 402 in L&M
clf
muj=0;
sigmaj=1; % sigmaj is the standard deviation; 1 for a standardnormal
y=linspace(-4.2,4.2,100);
% fyj=1/(sqrt(2*pi)*sigmaj)*exp(-1/2*((y-muj)/sigmaj).^2);
fyj=normpdf(y,muj,sigmaj);
% Plot using ax1 handle, saved above,to save this graph
% on top of the previous graph.
h1=line(y,fyj,'Color','r','Linewidth',3);
set(h1,'linestyle','--','color','r','linewidth',3)
axis([-4 4 0 0.41]);
ax1=gca;
set(ax1,'Ytick',[0:0.2:0.4],'YColor','b')
set(ax1,'Xtick',[-4:4],'YColor','b')
title( 'Figure 7.3.2','Fontsize',22);
% Now plot the t distribution with 10 df;
df=10;
%ftn=LMTheorem070402(df);  % find the pdf for t with 10 df.
ftn=tpdf(y,10);
h2=line(y,ftn,'Color','b');
set(h2,'linestyle','--','color','b','linewidth',3); 
df=2;
ftn=tpdf(y,2);
% ftn=LMTheorem070402(df);
h2=line(y,ftn,'Color','g');
set(h2,'linestyle','-.','color','g','linewidth',3);
% add labels
labs=['f_z(z)    ';
      'f_T_1_0(t)';
      'f_T_2(t)  '];
text(0.9,0.37,labs(1,:),'Color','r','Fontsize',18);
text(1.5,0.2,labs(2,:),'Color','b','Fontsize',18);
text(3,0.05,labs(3,:),'Color','g','Fontsize',18);
figure(gcf);pause