% LMEx030402_4th
% Example 3.4.2 p 164 in
% Larsen & Marx (2006) Introduction to Mathematical Statistics, 4th edition
% Written by Eugene.Gallagher@umb.edu for EEOS601
% http://alpha.es.umb.edu/faculty/edg/files/edgwebp.html
% Revised 1/12/2011
syms t 
% Could f(t)=3t^2 for 0 <= t <= 1 be used to define a continuous pdf?
% Does the definite integral sum to 1?
P=int(3*t^2,0,1)
fprintf('The definite integral of 3*t^2 from 0 to 1 is %2.1f.\',eval(P)) 
P1=int(3*t^2,0,1/3)
P2=int(3*t^2,2/3,1)
T=0:0.01:1;
Prob=3*T.^2;
plot(T,Prob);xlabel('t','FontSize',16);
ylabel('Probability density','FontSize',16)
axis([0 1.2 0 3]);
% Now fill in the areas
hold on;
T1=0:.01:1/3;yf=3*T1.^2;
fill([0 T1 1/3]',[0 yf 0]',[.8 .8 1])
text(.04,.3,'Area = 1/27','FontSize',18)
T2=2/3:.01:1;yf2=3*T2.^2;
fill([2/3 T2 1]',[0 yf2 0]',[.8 .8 1])
text(1.02,1.5,'Area = 19/27','FontSize',18)
title('Figure 3.4.4','FontSize',20)
figure(gcf);pause
hold off;
