0% found this document useful (0 votes)
50 views19 pages

02 Distributions

The document summarizes several common probability distributions including the binomial, geometric, Poisson, uniform, normal, exponential, Rayleigh distributions. It also discusses the Poisson approximation to the binomial distribution, the normal approximation to the binomial distribution using the DeMoivre–Laplace theorem, and illustrates the central limit theorem using dice rolls. Functions are provided to calculate probabilities for several of the distributions.

Uploaded by

gpaswathy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views19 pages

02 Distributions

The document summarizes several common probability distributions including the binomial, geometric, Poisson, uniform, normal, exponential, Rayleigh distributions. It also discusses the Poisson approximation to the binomial distribution, the normal approximation to the binomial distribution using the DeMoivre–Laplace theorem, and illustrates the central limit theorem using dice rolls. Functions are provided to calculate probabilities for several of the distributions.

Uploaded by

gpaswathy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 19

Some Useful Distributions

Binomial Distribution
æö
n÷ k
ç
p(k ) = ç ÷ p (1 - p ) n- k
, k = 0,1,..., n Bernoulli 1720
çk
èø ÷
÷

m= np s 2 = np(1- p)
k=0:20;
k=0:20;
y=binocdf(k,20,0.5);
y=binopdf(k,20,0.5);
stairs(k,y)
stem(k,y)
grid on
n = 20 p = 0.5
Binomial Distribution
function y=mybinomial(n,p)
for k=0:n
y(k+1)=factorial(n)/(factorial(k)*factorial(n-k))*p^k*(1-p)^(n-k)

end
k=0:20;
k=0:20; y=binopdf(k,20,0.1);
y=mybinomial(20,0.5); stem(k,y)
n = 20 p = 0.5
stem(k,y) n = 20 p = 0.1
Geometric Distribution

p(k ) = (1- p ) k - 1 p, k =1, 2,... Warning: Matlab assumes


1 1- p p(k ) = (1- p ) k p, k = 0,1, 2,...
2
m= s = 2
p p
k=0:20;
k=0:20; y=geocdf(k,0.5);
y=geopdf(k,0.5); stairs(k,y)
stem(k,y) axis([0 20 0 1])
p = 0.5
Geometric Distribution
function y=mygeometric(n,p)
for k=1:n
y(k)=(1-p)^(k-1)*p;
end

k=1:20; k=1:20;
y=mygeometric(20,0.5); y=mygeometric(20,0.1);
stem(k,y) stem(k,y)
p = 0.5 p = 0.1
Poisson Distribution
l k -l
p(k ) = e , k = 0,1,... Poisson 1837
k!
m= l s 2 =l
k=0:20;
k=0:20; y=poisscdf(k,5);
y=poisspdf(k,5); stem(k,y)
stem(k,y) grid on
l =5
Poisson Distribution
function y=mypoisson(n,lambda)
for k=0:n
y(k+1)=lambda^k/factorial(k)*exp(-lambda);
end
k=0:10; k=0:10;
y=mypoisson(10,0.1); y=mypoisson(10,2);
stem(k,y) stem(k,y)
axis([-1 10 0 1]) axis([-1 10 0 1])
l = 0.1 l =2
Uniform Distribution
1
f ( x) = , a£ x£ b
b- a
a +b 2 (b - a) 2
m= s =
2 12
x=0:0.1:8; x=0:0.1:8;
y=unifpdf(x,2,6); y=unifcdf(x,2,6);
plot(x,y) plot(x,y)
axis([0 8 0 0.5]) axis([0 8 0 2])
Normal Distribution
( x- m)2
1 -
f ( x) = e 2s 2
, - ¥ < x <¥ Gauss 1820
2ps
, 2)
N (ms
Warning: Matlab uses N (ms
, )
x=0:0.1:20;
x=0:0.1:20;
y=normcdf(x,10,2);
y=normpdf(x,10,2);
plot(x,y)
plot(x,y)
N (10, 4)
Normal Distribution
function y=mynormal(x,mu,sigma2)
y=1/sqrt(2*pi*sigma2)*exp(-(x-mu).^2/(2*sigma2));

x=-6:0.1:6;
y1=mynormal(x,0,1);
y2=mynormal(x,0,4);
plot(x,y1,x,y2,'r');
legend('N(0,1)','N(0,4)')
Exponential Distribution
f ( x ) = l e- l x , 0 £ x <¥
Warning: Matlab assumes
1 1 1 - lc
m= s2 = f ( x) = e , 0 £ x <¥
l l 2
l

x=0:0.1:5; x=0:0.1:5;
y=exppdf(x,1/2); y=expcdf(x,1/2);
plot(x,y) plot(x,y)
l =2
Exponential Distribution
function y=myexp(x,lambda)
y=lambda*exp(-lambda*x);

x=0:0.1:10;
y1=myexp(x,2);
y2=myexp(x,0.5);
plot(x,y1,x,y2,'r')
legend('lampda=2','lambda=0.5')
Rayleigh Distribution
x2
x -
2s 2
f ( x) = 2
e , x³ 0
s
p æ pö
m= s s 2 =ç
ç2- ÷
÷
÷s 2

2 ç
è 2ø

x=0:0.1:10;
y1=raylpdf(x,1);
y2=raylpdf(x,2);
plot(x,y1,x,y2,'r')
legend('sigma=1','sigma=2')
Poisson Approximation to Binomial

n? 1 p=1 np = l

æö
n ÷ l k
ç
ç ÷p k
(1 - p ) n - k
; e -l

èk ÷
ç ÷
ø k!

n=100;
p=0.1;
lambda=10;
k=0:n;
y1=mybinomial(n,p);
y2=mypoisson(n,lambda);
stem(k,y1)
hold on
stem(k,y2,’r’)
Normal Approximation to Binomial

DeMoivre – Laplace Theorem 1730


X - np
If X is a binomial RV Z= is approximately a standard
np (1- p)
normal RV
( k - np )2
æö
n÷ k 1 -
P[ X = k ] = ç
ç ÷
÷p (1 - p ) n- k
; e 2 np (1- p )
ç ÷
èk ø 2pnp(1- p)

k2 æö
n÷ k æ k - np ö ÷ æ k - np ö ÷
P[k1 £ X £ k 2 ] = å ç ÷ ç p (1 - p ) n- k
; F ç
ç 2 ÷- F ç
ç 1 ÷
ç ÷
÷ ç ÷
÷ ç ÷
÷
k =k1 èk ø ç
è np (1 - p ) ø è ç np (1 - p ) ø

A better approximation
æk + 0.5 - np ö
÷ æk - 0.5 - np ö
÷
ç
P[k1 £ X £ k2 ] ; F ç 2 ÷- F ç
ç 1 ÷
ç ÷
÷ ç ÷
÷
ç
è np(1- p) ø è ç np(1- p) ø
Normal Approximation to Binomial

function normbin(n,p)
clf
n = 10
y1=mybinomial(n,p);
k=0:n; p = 0.5
bar(k,y1,1,'w')
hold on
x=0:0.1:n;
y2=mynormal(x,n*p,n*p*(1-p));
plot(x,y2,'r')

n = 30
p = 0.5
Central Limit Theorem

function k=clt(n) % Central Limit Theorem for sum of dies


m=(1+6)/2; % mean (a+b)/2
s=sqrt(35/12); % standart deviation sqrt(((b-a+1)^2-1)/12)
for i=1:n
x(i,:)=floor(6*rand(1,10000)+1);
end
for i=1:length(x(1,:)) % sum of n dies
y(i)=sum(x(:,i));
z(i)=(sum(x(:,i))-n*m)/(s*sqrt(n));
end

subplot(2,1,1)
hist(y,100)
title('unormalized')
subplot(2,1,2)
hist(z,100)
title('normalized')
Central Limit Theorem
a +b
m= = 3.5
2

(b - a +1)2 - 1 n =1
2
s = = 2.92
12

n
unormalized = å X i
i =1

å X i - nm
n=2
normalized = i =1

s n
Central Limit Theorem

n =5

n = 10

You might also like