Upload
cristian-nazare
View
235
Download
0
Embed Size (px)
Citation preview
8/9/2019 Statistics - Distributions
1/36
Statistics - Distributions
Nazare Andrei-Cristian
University of Bucharest
Faculty of Mathematics and Informatics
January 20, 2015
1
8/9/2019 Statistics - Distributions
2/36
Contents
1 Geometric Distribution 3
2 Poisson Distribution 6
3 Binomial Distribution 9
4 Lognormal Distribution 12
5 Gamma Distribution 15
6 Chi-squared(2) Distribution 18
7 Generalised Paretto Distribution 21
8 Students T Distribution 24
9 Exponential Distribution 27
10 Beta Distribution 30
11 Normal (Gaussian) Distribution 33
12 Distribution Tests 36
2
8/9/2019 Statistics - Distributions
3/36
1 Geometric Distribution
Figure 1: Geometric Distribution
In probability theory and statistics,the geometric distribution is one oftwo discrete distributions:
If the probability of success oneach trial is p, then the probabilitythat the k-th trial (out of k trials) isthe first success is
Pr(X=k) = (1 p)k1pk0 NOr the following form of geomet-
ric distribution is used for modelingnumber of failures until the first suc-cess:
Pr(Y =k) = (1 p)kpfor k 1 NUsing the given MatLab code provided in this pdf, on a sample of 1000
random numbers with P=0.6, these values were found:
geom mean= 0.7100000000000000
geom std= 1.055942713888883
geom var= 1.115015015015019
(a) PMF (b) CDF
Figure 2: Geometric Distribution PMF and CDF
3
8/9/2019 Statistics - Distributions
4/36
MatLab code
c lo se a l l;r n d g e o=g e o r nd ( 0 . 6 , 1 , 1 0 0 0 ) ;r n d g e o 2=g e o r nd ( 0 . 3 5 , 1 , 1 0 0 0 ) ;mean geo=mean( r n d g e o ) ;mean geo2=mean( r n d g e o 2 ) ;v a r g e o =v a r ( r n d g e o ) ;s t d g e o =std ( r n d g e o ) ;k s b e t a =k s t e s t ( ( r n d g e om ea n g e o ) / s t d g e o ) ;l i l b e t a=l i l l i e t e s t ( rnd geo ) ;
k s 2 b e t a=k s t e s t 2 ( r n d g e o , r n d g e o 2 ) ;f igu r e;h i s t ( r n d g e o ) ;t i t l e( H i stogram ) ;xlabel ( V al ues ) ;ylabel ( Occurances ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\ h i s t g e o . png ) ;f igu r e;PDF = g e o pd f ( r n d g e o , 0 . 6 ) ;
plot ( rnd geo ,PDF, . ) ;hold on ;PDF2 = g e o p d f ( r n d g e o 2 , 0 . 3 5 ) ;plot ( rnd geo2 ,PDF2, ) ;t i t l e( PDF ) ;legend ( P=0.6 , P=0 .35 )xlabel ( V al ues ) ;ylabel ( P r o b a b i l i t y D e n si t y ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\p d f g e o . p ng ) ;f igu r e;
c d f p l o t ( r n d g e o ) ;hold on ;c d f = c d f p l o t ( r n d g e o 2 ) ;set ( cdf , Col or , r ) ;t i t l e( CDF ) ;legend ( P=0.6 , P=0 .35 )xlabel ( V al ues ) ;ylabel ( P r o b a b i l i t y ) ;set ( gcf, co l o r , w ) ;
4
8/9/2019 Statistics - Distributions
5/36
sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\ c d f g e o . p ng ) ;
To save the function histogram, pdf and cdf use
sav e as ( gcf, DRIVE: \ path\path\ f i l ena me . ex t )
5
8/9/2019 Statistics - Distributions
6/36
2 Poisson Distribution
Figure 3: Poisson Distribution
In probability theory and statistics,the Poisson distribution, named af-ter French mathematician SimeonDenis Poisson, is a discrete proba-bility distribution that expresses theprobability of a given number ofevents occurring in a fixed intervalof time and/or space if these eventsoccur with a known average rate andindependently of the time since thelast event.
The probability mass function(pmf) of the poisson distribution is
f(k; ) = Pr(X=k) = ke
k!
where >0 and k 0 N.Using the given MatLab code provided in this pdf, on a sample of 1000
random numbers with = 6, these values were found:
poiss mean= 4.911000000000000
poiss std= 2.195426814744429
poiss var= 4.819898898898869
(a) PMF (b) CDF
Figure 4: Poisson Distribution PDF and CDF
6
8/9/2019 Statistics - Distributions
7/36
MatLab code
c lo se a l l;r n d p o i s s=p o i s s r n d ( 5 , 1 , 1 0 0 0 ) ;r n d p o i s s 2=p o i s s r n d ( 6 , 1 , 1 0 0 0 ) ;mean poi ss=mean( r n d p o i s s ) ;v a r p o i s s=v ar ( r n d p o i s s ) ;s t d p o i s s =std ( r n d p o i s s ) ;k s p o i s s=k s t e s t ( ( r n d p o i s sm e a n p o i ss ) / s t d p o i s s ) ;l i l p o i s s = l i l l i e t e s t ( r n d p o i s s ) ;k s 2 p o i s s=k s t e s t 2 ( r n d p o i s s , r n d p o i s s 2 ) ;
f i t p o i s s o n =p o i s s f i t ( r n d p o i s s )f igu r e;h i s t ( r n d p o i s s ) ;t i t l e( H i stogram ) ;xlabel ( V al ues ) ;ylabel ( Occurances ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\ h i s t p o i s s . png ) ;f igu r e;PDF = p o i s s p d f ( r n d p o i s s , 5 ) ;
plot ( rn d po is s , PDF, . ) ;hold on ;PDF2 = p o i s s p d f ( r n d p o i s s 2 , 6 ) ;plot ( rn d po is s2 ,PDF2, ) ;t i t l e( PDF ) ;legend ( lambda = 5 , lambda = 6 )xlabel ( V al ues ) ;ylabel ( P r o b a b i l i t y D e n si t y ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\ p d f p o i s s . png ) ;f igu r e;
c d f p l o t ( r n d p o i s s ) ;hold on ;h = c d f p l o t ( r n d p o i s s 2 ) ;set (h , Col or , r ) ;t i t l e( CDF ) ;legend ( lambda = 5 , lambda = 6 )xlabel ( V al ues ) ;ylabel ( P r o b a b i l i t y ) ;set ( gcf, co l o r , w ) ;
7
8/9/2019 Statistics - Distributions
8/36
sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\ c d f p o i s s . p ng ) ;
To save the function histogram, pdf and cdf use
sav e as ( gcf, DRIVE: \ path\path\ f i l ena me . ex t )
8
8/9/2019 Statistics - Distributions
9/36
3 Binomial Distribution
Figure 5: Binomial Distribution
In probability theory and statistics,the binomial distribution with pa-rameters n and p is the discreteprobability distribution of the num-ber of successes in a sequence of n in-dependent yes/no experiments, eachof which yields success with proba-bility p.
In general, if the random variable
X follows the binomial distributionwith parameters n and p, we writeformula. The probability of get-ting exactly k successes in n trials isgiven by the probability mass func-tion:
f(k; n, p) = Pr(X=k) =nk
pk(1 p)nk for k = 0, 1, 2, ..., n.
Using the given MatLab code provided in this pdf, on a sample of 1000random numbers with n= 5 and p = 10, these values were found:
fit norm mean= 4.673680399039023
fit norm std= 9.989653227188306
norm var= 99.793171599473720
(a) PDF (b) CDF
Figure 6: Binomial Distribution PDF and CDF
9
8/9/2019 Statistics - Distributions
10/36
MatLab code
c lo se a l l;r n d b i n o=b i n o r n d ( 1 0 0 0 , 0 . 9 , 1 0 0 0 , 1 ) ;r n d b i n o 2=b i n o r n d ( 1 0 0 0 , 0 . 7 , 1 0 0 0 , 1 ) ;mean bino=mean( r n d b i n o ) ;v a r b i n o =v a r ( r n d b i n o ) ;s t d b i n o =std ( r n d b i n o ) ;k s b i n o =k s t e s t ( ( r n d b i n om ea n b in o ) / s t d b i n o ) ;l i l b i n o=l i l l i e t e s t ( rnd bi no ) ;k s 2 b i n o =k s t e s t 2 ( r n d b i n o , r n d b i n o 2 ) ;
[ p ha t , p c i ] = b i n o f i t ( r n d b i n o , 1 0 0 0 ) ;[ p ha t2 , p c i 2 ] = b i n o f i t ( r n d b i n o2 , 1 0 0 0 ) ;f igu r e;h i s t ( r n d b i n o ) ;t i t l e( H i stogram ) ;xlabel ( V al ues ) ;ylabel ( Occurances ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\ h i s t b i n o . png ) ;f igu r e;
MAX = max( r n d b i n o ) ;MIN = min( r n d b i n o ) ;STEP = (MAX MIN) / 1 0 0 0 ;MAX2 = max( r n d b i n o 2 ) ;MIN2 = min( r n d b i n o 2 ) ;STEP2 = (MAX2 MIN2) / 100 0;PDF2 = bin opd f (0 :1 00 0 ,1 00 0 , phat2 : phat2 ) ;PDF = bin opd f (0 :1 00 0 ,1 00 0 , phat : phat ) ;plot (MIN : STEP:MAX,PDF)hold on ;plot (MIN2:STEP2:MAX2,PDF2, r )
t i t l e( PDF ) ;legend ( N=1000 P=0.9 , N=1000 P=0.7 )xlabel ( V al ues ) ;ylabel ( P r o b a b i l i t y D e n si t y ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\p d f b i n o . p ng ) ;f igu r e;c d f p l o t ( r n d b i n o ) ;hold on ;
10
8/9/2019 Statistics - Distributions
11/36
h = c d f p l o t ( r n d b i n o 2 ) ;
set (h , Col or , r ) ;t i t l e( CDF ) ;legend ( N=1000 P=0.9 , N=1000 P=0.7 )xlabel ( V al ues ) ;ylabel ( P r o b a b i l i t y ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\ c d f b i n o . p ng ) ;
To save the function histogram, pdf and cdf use
sav e as ( gcf, DRIVE: \ path\path\ f i l ena me . ex t )
11
8/9/2019 Statistics - Distributions
12/36
4 Lognormal Distribution
Figure 7: Lognormall Distri-
bution
In probability theory, a lognormal distri-bution is a continuous probability distribu-tion of a random variable whose logarithm isnormally distributed. Thus, if the randomvariable X is log-normally distributed,thenY= log(X) has a normal distribution. Like-wise, if Y has a normal distribution, thenX= exp(Y) has a log-normal distribution.A random variable which is log-normally
distributed takes only positive real values.
The probability density function of a log-normal distribution is:
fX(x; , ) = 1x2
e(lnx)2
22
The mean of the lognormal distribution is: e+2/2
The variance of the distribution is: (e2 1)e2+
2
Using the given MatLab code provided in this pdf, on a sample of 1000random numbers with = 0.5 and = 0.6, these values were found:
logn mean= 4.673680399039023
logn std= 9.989653227188306
logn var = 99.793171599473720
(a) PDF (b) CDF
Figure 8: Lognormal Distribution PDF and CDF
12
8/9/2019 Statistics - Distributions
13/36
MatLab code
c lo se a l l;r n d l o g n =l o g n r n d ( 0 . 5 , 1 , 1 , 1 0 0 0 ) ;r n d l o g n 2 =l o g n r n d ( 1 , 0 . 9 , 1 , 1 0 0 0 ) ;mean logn=mean( r n d l o g n ) ;mean logn2=mean( r n d l o g n 2 ) ;v a r l o g n =v a r ( r n d l o g n ) ;s t d l o g n =std ( r n d l o g n ) ;k s l o g n =k s t e s t ( ( r n d l o g nm ea n l og n ) / s t d l o g n ) ;l i l l o g n=l i l l i e t e s t ( rnd l og n );
k s 2 l o g n =k s t e s t 2 ( r n d l o g n , r n d l o g n 2 ) ;p ar mh at = l o g n f i t ( r n d l o g n )f igu r e;h i s t ( r n d l o g n ) ;t i t l e( H i stogram ) ;xlabel ( V al ues ) ;ylabel ( Occurances ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\ h i s t l o g n . png ) ;f igu r e;
MAX = max( r n d l o g n ) ;MIN = min( r n d l o g n ) ;STEP = (MAX MIN) / 1 0 0 0 ;PDF = l o g n p d f (MIN: STEP :MAX, me an lo gn ) ;MAX2 = max( r n d l o g n 2 ) ;MIN2 = min( r n d l o g n 2 ) ;STEP2 = (MAX2 MIN2) / 100 0;PDF2 = lo g n p df (MIN2 : STEP2 :MAX2, me an log n2 ) ;plot (MIN : STEP:MAX,PDF)hold on ;plot (MIN2:STEP2:MAX2,PDF2, r )
t i t l e( PDF ) ;legend ( mu=0.5 sigm a=1 , mu=1 sigma =0.9 )xlabel ( V al ues ) ;ylabel ( P r o b a b i l i t y D e n si t y ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\ p d f l o g n . p ng ) ;f igu r e;c d f p l o t ( r n d l o g n ) ;hold on ;
13
8/9/2019 Statistics - Distributions
14/36
h = c d f p l o t ( r n d l o g n 2 ) ;
set (h , Col or , r ) ;t i t l e( CDF ) ;legend ( mu=0.5 sigm a=1 , mu=1 sigma =0.9 )xlabel ( V al ues ) ;ylabel ( P r o b a b i l i t y ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\ c d f l o g n . png ) ;
To save the function histogram, pdf and cdf use
sav e as ( gcf, DRIVE: \ path\path\ f i l ena me . ex t )
14
8/9/2019 Statistics - Distributions
15/36
5 Gamma Distribution
Figure 9: Gamma Distribution
Gamma distribution is a distribution thatarises naturally in processes for which thewaiting times between events are relevant.It can be thought of as a waiting time be-tween Poisson distributed events.
The Gamma Distribution PDF is:f(x,,) =
()x 1ex for x
0and , > 0Using the given MatLab code provided in
this pdf, on a sample of 1000 random num-bers with = 5 and = 6, these valueswere found:
gamma mean= 30.162384340621220
gamma std= 13.571216505655352
gamma var= 184.1779174433723
phat= (5.04447391274990, 5.97929236275479)
(a) PDF (b) CDF
Figure 10: Gamma Distribution PDF and CDF
15
8/9/2019 Statistics - Distributions
16/36
MatLab code
c lo se a l l;rnd gam=gamrnd( 5 ,6 ,1 ,1 00 0) ;rnd gam2=gamrnd( 6 ,5 ,1 ,1 00 0) ;mean gam=mean( rnd gam ) ;var gam=var ( rnd gam ) ;std gam=std ( rnd gam ) ;k s gam=k s te st (( rnd gammean gam)/ std gam ) ;l il g a m=l i l l i e t e s t ( rnd gam ) ;ks2 gam=ks te st 2 ( rnd gam , rnd gam2 ) ;
[ phat , pc i ] = gamfi t ( rnd gam )[ phat2 , pci 2 ] = gamfi t ( rnd gam2)f igu r e;h i s t ( rnd gam ) ;t i t l e( H i stogram ) ;xlabel ( V al ues ) ;ylabel ( Occurances ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\hi st gam . png ) ;f igu r e;
MAX = max( rnd gam ) ;MIN = min( rnd gam ) ;STEP = (MAX MIN) / 1 0 0 0 ;PDF = gampdf (MIN: STEP :MAX, ph at (1 ) , ph at ( 2 ) ) ;MAX2 = max( rnd gam2 ) ;MIN2 = min( rnd gam2 ) ;STEP2 = (MAX2 MIN2) / 100 0;PDF2 = gampdf (MIN2 : STEP2 :MAX2, pha t2 (1 ) , pha t2 ( 2 ) ) ;plot (MIN : STEP:MAX,PDF)hold on ;plot (MIN2:STEP2:MAX2,PDF2, r )
t i t l e( PDF ) ;legend ( forma=5 sca ra=6 , forma=6 sca ra=5 )xlabel ( V al ues ) ;ylabel ( P r o b a b i l i t y D e n si t y ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\pdf gam . png );f igu r e;c d f p l o t ( r n d g am ) ;hold on ;
16
8/9/2019 Statistics - Distributions
17/36
h = c d f p l o t ( r n d g am 2 ) ;
set (h , Col or , r ) ;t i t l e( CDF ) ;legend ( forma=5 sca ra=6 , forma=6 sca ra=5 )xlabel ( V al ues ) ;ylabel ( P r o b a b i l i t y ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\cdf gam . png ) ;
To save the function histogram, pdf and cdf use
sav e as ( gcf, DRIVE: \ path\path\ f i l ena me . ex t )
17
8/9/2019 Statistics - Distributions
18/36
6 Chi-squared(2) Distribution
Figure 11: Normal Distribution
In probability theory and statistics,the chi-squared distribution (alsochi-square or2-distribution) with kdegrees of freedom is the distributionof a sum of the squares of k indepen-dent standard normal random vari-ables.
The probability density function(pdf) of the chi-squared distributionis
f(x) = ex2 x
21
22(
2)
for x 0 where
v is the shape parameter and isthe gamma function. The formulafor the gamma function is: (a) =0
ta1etdtUsing the given MatLab code provided in this pdf, on a sample of 1000
random numbers with v= 6, these values were found:
chi2 mean= 5.883551961538731
chi2 std= 3.488680834121589
chi2 var = 12.170893962367305
(a) PDF (b) CDF
Figure 12: Chi-squared Distribution PDF and CDF
18
8/9/2019 Statistics - Distributions
19/36
MatLab code
c lo se a l l;r n d c h i 2 =c h i 2 r n d ( 6 , 1 , 1 0 0 0 ) ;r n d c h i 2 2 =c h i 2 r n d ( 5 , 1 , 1 0 0 0 ) ;mean chi2=mean( r n d c h i 2 ) ;mean chi22=mean( r n d c h i 2 2 ) ;v a r c h i 2 =v a r ( r n d c h i 2 ) ;s t d c h i 2 =std ( r n d c h i 2 ) ;k s c h i 2=k s t e s t ( ( r n d c h i 2m ea n c h i2 ) / s t d c h i 2 ) ;l i l c h i 2=l i l l i e t e s t ( rnd ch i 2 ) ;
k s 2 c h i 2 =k s t e s t 2 ( r n d c h i 2 , r n d c h i 2 2 ) ;f igu r e;h i s t ( r n d c h i 2 ) ;t i t l e( H i stogram ) ;xlabel ( V al ues ) ;ylabel ( Occurances ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\ h i s t c h i 2 . png ) ;f igu r e;
MAX = max( r n d c h i 2 ) ;
MIN = min( r n d c h i 2 ) ;STEP = (MAX MIN) / 1 0 0 0 ;MAX2 = max( r n d c h i 2 2 ) ;MIN2 = min( r n d c h i 2 2 ) ;STEP2 = (MAX2 MIN2) / 100 0;PDF = c h i 2 p d f (MIN: STEP:MAX, me an ch i2 ) ;plot (MIN:STEP:MAX,PDF, r )hold on ;PDF2 = c h i2 p d f (MIN2 : STEP2 :MAX2, me an ch i2 2 ) ;plot (MIN2: STEP2:MAX2, PDF2)t i t l e( PDF ) ;
legend ( mean=5 , mean=6 )xlabel ( V al ues ) ;ylabel ( P r o b a b i l i t y D e n si t y ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\ p d f c h i 2 . p ng ) ;f igu r e;c d f p l o t ( r n d c h i 2 ) ;hold on ;h = c d f p l o t ( r n d c h i 2 2 ) ;
19
8/9/2019 Statistics - Distributions
20/36
set (h , Col or , r ) ;
t i t l e( CDF ) ;legend ( mean=5 , mean=6 )xlabel ( V al ues ) ;ylabel ( P r o b a b i l i t y ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\ c d f c h i 2 . png ) ;
To save the function histogram, pdf and cdf use
sav e as ( gcf, DRIVE: \ path\path\ f i l ena me . ex t )
20
8/9/2019 Statistics - Distributions
21/36
7 Generalised Paretto Distribution
Figure 13: Paretto Distribution
In probability theory and statistics,the chi-squared distribution (alsochi-square or2-distribution) with kdegrees of freedom is the distributionof a sum of the squares of k indepen-dent standard normal random vari-ables.
The probability density function(pdf) of the generalised paretto dis-tribution is
f(k,,)(x) = 1
1 + k(x)
( 1k1)x when k 0,and x
/k when k < 0.Using the given MatLab code
provided in this pdf, on a sample of 1000 random numbers with k = 0.5, = 1and = 1, these values were found:
gp mean= 2.384013067341135
gp std= 1.646044219236448
gp var= 2.709461571681729
(a) PDF (b) CDF
Figure 14: Generalised Paretto Distribution PDF and CDF
21
8/9/2019 Statistics - Distributions
22/36
MatLab code
c lo se a l l;rnd gp=gprnd (0 , 1 , 0 , 1 , 10 00 );rnd gp2=gprnd (0 , 2 , 1 , 1 , 10 00 );mean gp=mean( r n d g p ) ;v a r g p=v a r ( r n d g p ) ;s t d g p =std ( r nd g p ) ;k s g p= k s t e s t ( ( r n d g pmean gp)/ std gp ) ;l i l g p= l i l l i e t e s t ( rnd gp );k s 2 g p= k s t e s t 2 ( r n d g p , r n d g p 2 ) ;
[ muhat , m uc i ] = g p f i t ( r n d g p )f igu r e;h i s t ( r nd g p ) ;t i t l e( H i stogram ) ;xlabel ( V al ues ) ;ylabel ( Occurances ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\ h i s t g p . p ng ) ;f igu r e;
MAX = max( r nd g p ) ;
MIN = min( r nd g p ) ;STEP = (MAX MIN) / 1 0 0 0 ;MAX2 = max( r n d g p 2 ) ;MIN2 = min( r n d g p 2 ) ;STEP2 = (MAX2 MIN2) / 100 0;PDF2 = gp pd f (MIN2 : STEP2 :MAX2, 0 ,2 , 0 ) ;PDF = gp pd f (MIN: STEP :MAX, 0 , 1 , 0 ) ;plot (MIN: STEP:MAX,PDF) ;hold on ;plot (MIN2: STEP2 :MAX2, PDF2, r ) ;t i t l e( PDF ) ;
legend ( k=0 sigma=1 th et a=0 , k=0 sigma=2 th et a=1 )xlabel ( V al ues ) ;ylabel ( P r o b a b i l i t y D e n si t y ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\pdf gp . png ) ;f igu r e;c d f p l o t ( r nd g p ) ;hold on ;h = c d f p l o t ( r nd g p2 ) ;
22
8/9/2019 Statistics - Distributions
23/36
8/9/2019 Statistics - Distributions
24/36
8 Students T Distribution
Figure 15: T Distribution
In probability and statistics, Stu-dents t-distribution (or simply thet-distribution) is any member ofa family of continuous probabilitydistributions that arises when es-timating the mean of a normallydistributed population in situationswhere the sample size is small andpopulation standard deviation is un-known
Students t-distribution has theprobability density function givenby:
f(x, v) = ( +12 ) ( 2 )
1 + x
2
+12Using the given MatLab code provided in this pdf, on a sample of 1000
random numbers with v= 5, these values were found:
t mean= 0.032820938812743
t std= 1.295208768745536
t var = 1.677565754635327
(a) PDF (b) CDF
Figure 16: T Distribution PDF and CDF
24
8/9/2019 Statistics - Distributions
25/36
MatLab code
c lo se a l l;r n d t=t r n d ( 5 , 1 , 1 0 0 0 ) ;r n d t 2=t r n d ( 2 3 , 1 , 1 0 0 0 ) ;mean t=mean( r n d t ) ;v a r t=v a r ( r n d t ) ;s t d t =std ( r n d t ) ;k s t =k s t e s t ( ( r n d tm ea n t ) / s t d t ) ;l i l t = l i l l i e t e s t ( rn d t ) ;k s 2 t=k s t e s t 2 ( r n d t , r n d t 2 ) ;
f igu r e;h i s t ( r n d t ) ;t i t l e( H i stogram ) ;xlabel ( V al ues ) ;ylabel ( Occurances ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\ h i s t t . png ) ;f igu r e;
MAX = max( r n d t ) ;MIN = min( r n d t ) ;
STEP = (MAX MIN) / 1 0 0 0 ;MAX2 = max( r n d t 2 ) ;MIN2 = min( r n d t 2 ) ;STEP2 = (MAX2 MIN2) / 100 0;PDF2 = t p d f (MIN2 : STEP2 :MAX2, 2 3 ) ;PDF = t p d f (MIN: STEP :MAX, 5 ) ;plot (MIN : STEP:MAX,PDF)hold on ;plot (MIN2:STEP2:MAX2,PDF2, r )t i t l e( PDF ) ;legend ( Grad d e l i b e r t a t e =5 , Grad d e l i b e r t a t e =23 )
xlabel ( V al ues ) ;ylabel ( P r o b a b i l i t y D e n si t y ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\ p d f t . pn g ) ;f igu r e;c d f p l o t ( r n d t ) ;hold on ;h = c d f p l o t ( r n d t 2 ) ;set (h , Col or , r ) ;
25
8/9/2019 Statistics - Distributions
26/36
t i t l e( CDF ) ;
legend ( Grad d e l i b e r t a t e =5 , Grad d e l i b e r t a t e =23 )xlabel ( V al ues ) ;ylabel ( P r o b a b i l i t y ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\ c d f t . pn g ) ;
To save the function histogram, pdf and cdf use
sav e as ( gcf, DRIVE: \ path\path\ f i l ena me . ex t )
26
8/9/2019 Statistics - Distributions
27/36
9 Exponential Distribution
Figure 17: Exponential Distribution
The exponential distribution de-scribes the arrival time of a ran-domly recurring independent eventsequence. If is the mean waitingtime for the next event recurrence,its probability density function is:
f(x, ) = 1
ex
Where > 0 is the mean andstandard deviation of the distribu-
tion.Using the given MatLab code
provided in this pdf, on a sample of1000 random numbers with = 6,these values were found:
fit exp mean= 6.201096603372848
exp std= 6.462512315745626
exp var = 41.764065431163885
(a) PDF (b) CDF
Figure 18: Exponential Distribution PDF and CDF
27
8/9/2019 Statistics - Distributions
28/36
MatLab code
c lo se a l l;rnd ex p=ex prnd (3 , 1 , 1 00 0) ;rnd ex p2=ex prnd (5 , 1 , 1 00 0) ;mean exp=mean( r n d e xp ) ;mean exp2=mean( r n d e x p 2 ) ;v a r e x p=v a r ( r n d e x p ) ;s t d e x p =std ( r n d e x p ) ;k s e x p= k s t e s t ( ( r n d e x pmean ex p)/ std ex p ) ;l i l e x p=l i l l i e t e s t ( rnd ex p ) ;
k s 2 e x p= k s t e s t 2 ( r n d e x p , r n d e x p 2 ) ;[ muhat , m uc i ] = e x p f i t ( r n d e x p ) ;f igu r e;h i s t ( r n d e xp ) ;t i t l e( H i stogram ) ;xlabel ( V al ues ) ;ylabel ( Occurances ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\ h i s t e x p . p ng ) ;f igu r e;
MAX = max( r n d e xp ) ;MIN = min( r n d e xp ) ;STEP = (MAX MIN) / 1 0 0 0 ;PDF = ex pp df (MIN: STEP :MAX, mea n exp ) ;MAX2 = max( r n d e x p 2 ) ;MIN2 = min( r n d e x p 2 ) ;STEP2 = (MAX2 MIN2) / 100 0;PDF2 = ex pp df (MIN2 : STEP2: MAX2, mea n exp 2 ) ;plot (MIN : STEP:MAX,PDF)hold on ;plot (MIN2:STEP2:MAX2,PDF2, r )
t i t l e( PDF ) ;legend ( mu=3 , mu=5 )xlabel ( V al ues ) ;ylabel ( P r o b a b i l i t y D e n si t y ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\pdf ex p . png ) ;f igu r e;c d f p l o t ( r nd e xp ) ;hold on ;
28
8/9/2019 Statistics - Distributions
29/36
h = c d f p l o t ( r nd e x p2 ) ;
set (h , Col or , r ) ;t i t l e( CDF ) ;legend ( mu=3 , mu=5 )xlabel ( V al ues ) ;ylabel ( P r o b a b i l i t y ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\ c d f e x p . p ng ) ;
To save the function histogram, pdf and cdf use
sav e as ( gcf, DRIVE: \ path\path\ f i l ena me . ex t )
29
8/9/2019 Statistics - Distributions
30/36
10 Beta Distribution
Figure 19: Poisson Distribution
In probability theory and statistics,the beta distribution is a familyof continuous probability distribu-tions defined on the interval [0, 1]parametrized by two positive shapeparameters, denoted by a nd ,that appear as exponents of the ran-dom variable and control the shapeof the distribution.
The probability density function(pdf) of the beta distribution is
f(x; , ) = 1B(,)
x1(1x)1
for 0 x 1 and , >0Using the given MatLab code
provided in this pdf, on a sample of 1000 random numbers with =5and = 10, these values were found:
beta mean= 5.338001186132061
beta std= 10.599206839273960 beta var= 0.013223922101963
(a) PDF (b) CDF
Figure 20: Beta Distribution PDF and CDF
30
8/9/2019 Statistics - Distributions
31/36
MatLab code
c lo se a l l;r n d b e t a =b e t a r n d ( 5 , 1 0 , 1 0 0 0 , 1 ) ;r n d b e t a 2 =b e t a r n d ( 5 , 1 3 , 1 0 0 0 , 1 ) ;mean beta=mean( r n d b e t a ) ;v a r b e t a =v a r ( r n d b e t a ) ;s t d b e t a =std ( r n d b e t a ) ;mean beta2=mean( r n d b e t a 2 ) ;v a r b e t a 2=v a r ( r n d b e t a 2 ) ;s t d b e t a 2 =std ( r n d b e t a 2 ) ;
[ f i t b e t a m e a n , f i t b e t a s t d ]= b e t a f i t ( r n d b e t a ) ;k s b e t a =k s t e s t ( ( r n d b e t am ea n b e t a ) / s t d b e t a ) ;l i l b e t a=l i l l i e t e s t ( rnd beta ) ;k s 2 b e t a =k s t e s t 2 ( r n d b e t a , r n d b e t a 2 ) ;f igu r e;h i s t ( r n d b e t a ) ;t i t l e( H i stogram ) ;xlabel ( V al ues ) ;ylabel ( Occurances ) ;set ( gcf, co l o r , w ) ;
sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\ h i s t b e t a . png ) ;f igu r e;MAX = max( r n d b e t a ) ;MIN = min( r n d b e t a ) ;MAX2 = max( r n d b e t a 2 ) ;MIN2 = min( r n d b e t a 2 ) ;STEP = (MAX MIN) / 1 0 0 0 ;STEP2 = (MAX2 MIN2) / 100 0;PDF = be ta pd f (MIN: STEP:MAX, mean beta , st d b e t a ) ;plot (MIN:STEP:MAX,PDF, r )hold on ;
PDF2 = be ta pd f (MIN2 : STEP2 :MAX2, mean beta2 , st d b e t a 2 ) ;plot (MIN:STEP:MAX,PDF2)t i t l e( PDF ) ;legend ( A=5 B=10 , A=5 B=13 )xlabel ( V al ues ) ;ylabel ( P r o b a b i l i t y D e n si t y ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\p d f b e t a . p ng ) ;f igu r e;
31
8/9/2019 Statistics - Distributions
32/36
c d f p l o t ( r n d b e t a ) ;
hold on ;h = c d f p l o t ( r n d b e t a 2 ) ;set (h , Col or , r ) ;legend ( A=5 B=10 , A=5 B=13 )t i t l e( CDF ) ;xlabel ( V al ues ) ;ylabel ( P r o b a b i l i t y ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\ c d f b e t a . p ng ) ;
To save the function histogram, pdf and cdf use
sav e as ( gcf, DRIVE: \ path\path\ f i l ena me . ex t )
32
8/9/2019 Statistics - Distributions
33/36
11 Normal (Gaussian) Distribution
Figure 21: Normal Distribution
A normal distribution is:
f(x,,) = 12
e(x)2
22
If = 0 and = 1, the distri-bution is called the standard nor-mal distribution. The parameter in this definition is the mean orexpected value of the distribution.The parameter is its standard de-viation; its variance is therefore 2.
A random variable with a Gaussiandistribution is said to be normallydistributed and is called a normaldeviate.
Using the given MatLab codeprovided in this pdf, on a sample of 1000 random numbers with = 5and = 10, these values were found:
fit norm mean= 4.673680399039023
fit norm std= 9.989653227188306
norm var= 99.793171599473720
(a) PDF (b) CDF
Figure 22: Normal Distribution PDF and CDF
33
8/9/2019 Statistics - Distributions
34/36
8/9/2019 Statistics - Distributions
35/36
c d f p l o t ( r nd n or m ) ;
hold on ;h = c d f p l o t ( r n d n o rm 2 ) ;set (h , Col or , r ) ;legend ( mean=5 va ri an ce =10 , mean=6 va ri an ce =13 )t i t l e( CDF ) ;xlabel ( V al ues ) ;ylabel ( P r o b a b i l i t y ) ;set ( gcf, co l o r , w ) ;sav e as ( gcf, C:\ U sers \ c r i s t 0 0 0 \Documents\LateX\ cdf norm . png ) ;
To save the function histogram, pdf and cdf use
sav e as ( gcf, DRIVE: \ path\path\ f i l ena me . ex t )
35
8/9/2019 Statistics - Distributions
36/36
12 Distribution Tests
The folowing table contains the values resulting from the one-sample Kolmogorov-Smirnov test (kstest), the two-sample Kolmogorov-Smirnov test (sktest2) andthe Lilliefors test (lilietest).
DistributionTest
kstest kstest2 liliietest
Geometric 1 1 1Poisson 1 1 1Binomial 0 1 1Lognormal 1 1 1Gamma 1 0 1Chi-squared 1 1 1Paretto 1 0 1T 1 0 1Exponential 1 1 1Beta 1 1 1Normal 0 1 0
36