Method 1: Use built-in functions (requires Statistics toolbox)
Using exppdf()
and tpdf()
is easy but requires the Statistics Toolbox. If you don't have those functions then you can always directly code the PDF functions (Student's t and Exponential) as in Method 2 below.
Note that MATLAB parameterizes the Exponential distribution by the mean which is the inverse of the rate (lambda
).
lambda = 5;
nu = 15;
Xrng = 0:.01:2;
Yrng = -5:.01:5;
figure
subplot(1,2,1)
plot(Xrng,exppdf(Xrng,1/lambda),'k-')
subplot(1,2,2)
plot(Yrng,tpdf(Yrng,nu),'b-')
Method 2: Hard-code PDF functions directly (no toolbox required)
You can always directly code the PDF functions (Student's t and Exponential).
fexph =@(x) lambda*exp(-lambda*x);
fth =@(x) (1/(sqrt(nu)*beta(0.5,0.5*nu)))*((1+((x.^2)./nu)).^(-0.5*(nu+1)));
figure
subplot(1,2,1)
plot(Xrng,fexph(Xrng),'k-')
subplot(1,2,2)
plot(Yrng,fth(Yrng),'b-')