%
%
%
%
%
%
%disttool is a tool to plot various PDF and CDF
disttool;
%pdf and cdf functions can be used to generate all
%probability distributions.
%x=0:10;
%y=poisspdf(x,5);
%%stem(x,y)
%plot(x,y,'+');
clc;
clear;
%exppdf and expcdf can be used directly
figure(1);
x=0:.025:5;
yd=exppdf(x);
yp=expcdf(x);
subplot(2,1,1)
plot(x,yd)
title('Standard Exponential Density Function')
subplot(2,1,2)
plot(x,yp)
title('Standard Exponential Distribution Function')
%
% %normpdf and normcdf can be used directly
figure(2);
xn= -3:.03:3;
ydn= normpdf(xn);
subplot(2,1,1)
plot(xn,ydn)
title('Standard Normal Density Function')
subplot(2,1,2)
plot(xn,normcdf(xn))
title('Standard Normal Distribution Function')
%
% %The binomial and Poisson are the most important discrete random variables.
% %binopdf and poisspdf are the MATLAB functions for the probability
% %mass functions of these random variables.
%
figure(3);
x=0:10;
y=binopdf(x,10,.5);
%stem(x,y)
subplot(2,1,1)
plot(x,y,'+');
title('Binomial Distribution Function')
subplot(2,1,2)
plot(x,binocdf(x,10,.5))
title('Cummulative Binomial Distribution Function')
%
% %The cumulative distribution function is useful for computing probabilities
% %that a binomial random variable lies in a range. For example, suppose
% %we needed to compute the probability that a binomial random variable X
% %with success probability .2 lies between 2 and 8. Actually, that is
% %Pr(2 < X < 8) = Pr(2 < X <= 7) = Pr( X <= 7) - Pr( X <=2)
% % is binocdf(7,10,.2)-binocdf(2,10,.2)
% %ans =
% %
0.3221
% figure(2);
% x=0:10;
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
e
%
%
%
%
%
%
%
)
%
%
y=binocdf(x,10,.2);
stairs(x,y)
axis ([-1 11 0 1.1])
% It is useful to generate random variables from a specific distribution.
% In MATLAB, we only need to add "rnd" (for random) to any of the
% distribution names in the above table to generate data from that
% distribution. For example, to generate a sample of 6 independent
% random variables from the normal distribution with mean 3 and
% standard deviation 2, we would type:
normrnd(3,2,[1 6])
%If one prefers a column vector, then type
normrnd(3,2,[6 1])
%
% Distribution
Usage
% binomial
% chisquared
% exponential
% gamma
% normal
% Poisson
% Student's t
% uniform
% Weibull
M-Function
bino
chi2
Parameters
(with default values)
Exampl
exp
gam
norm
poiss
t
N, p (no default)
binopdf(x,20,.7)
df (no default)
chi2pdf(x,4)
beta=1
exppdf(x,3)
alpha=1 (no default for beta) gampdf(x,2,3)
mean=0, sd=1
normpdf(x,2,5)
lambda (no default)
poisspdf(x,3)
df
no default)
tpdf(x,7
unif
weib
min=0,max=1
alpha,beta (no default)
unifpdf(x,5,20)
weibpdf(x,4,2)