% 
% Matlab - ch3.m Generating p.d.f. and plot for various distributions
close all
% 
% 4. exppdf(X,t)     5. chi2pdf(X,r), 
% 6. normpdf(X,u,s)  7. gampdf(X,a,r) 
% 8. unifpdf(X,a,b)
%
% 4. Exponential Distribution - exppdf(X,t)
%
subplot(2,2,1)
X=0.1:0.1:12;
Ya=exppdf(X,1); Yb=exppdf(X,2); Yc=exppdf(X,4); Yd=exppdf(X,7);
plot(X,Ya,'r-',X,Yb,'g-',X,Yc,'b-',X,Yd,'m-'); %axis([0,12, 0,0.3])
legend('Exp(1)','Exp(2)','Exp(4)','Exp(7)')
title('(4) Exponential(\theta), \theta=1,2,4,7')
% 
%
% 5. Chi-Square Distribution - chi2pdf(X,r)
%
subplot(2,2,2)
X=0.1:0.1:12;
Y1=chi2pdf(X,1); Y2=chi2pdf(X,2); Y4=chi2pdf(X,4); Y7=chi2pdf(X,7);
plot(X,Y1,'r-',X,Y2,'g-',X,Y4,'b-',X,Y7,'m-'); %axis([0,12, 0,0.3])
legend('\chi^2(1)','\chi^2(2)','\chi^2(4)','\chi^2(7)')
title('(5) \chi^2(r), r=1,2,4,7')
%
% 6. Normal Distribution - normpdf(X,u,s)
%
subplot(2,2,3)
X7=-6:0.2:6;   u=0;  s1=1;  s2=2;  s3=2.5;  s4=3;
Y7a=normpdf(X7,u,s1); Y7b=normpdf(X7,u,s2); Y7c=normpdf(X7,u,s3);
Y7d=normpdf(X7,u,s4);
plot(X7,Y7a,'r-',X7,Y7b,'g-',X7,Y7c,'b-',X7,Y7d,'m-');axis([-6,6, 0,0.42])
legend('N(0,1)','N(0,4)','N(0,6.25)','N(0,9)')
title('(6) Normal Distribution:  N(u,s^2)')
%
% 7. Gamma Distribution - gampdf(X,a,t)
%
subplot(2,2,4)
X6=0.1:0.1:12; t1=2; t2=3; t3=4; t4=4;
Y6a=gampdf(X6,3,t1); Y6b=gampdf(X6,3,t2); 
Y6c=gampdf(X6,2,t4); Y6d=gampdf(X6,4,t4);
plot(X6,Y6a,'r-',X6,Y6b,'g-',X6,Y6c,'b-',X6,Y6d,'m-'); %axis([0,12, 0,0.3])
legend('\Gamma(3,2)','\Gamma(3,3)','\Gamma(2,4)','\Gamma(4,4)')
title('(7) \Gamma(\alpha, \lambda)')
%--------------------------------------------------------------------------
%
% 8. Uniform Distribution
% X1=0:0.01:1;  Y1=unifpdf(X1,0,1);  plot(X1,Y1,'r-'); 
% title((9) 'Uniform Distribution U(0,1)')
%
