Binomial Distribution

Binomial and Geometric Distributions
Delta On-Time Performance at HartsfieldJackson Atlanta International (June, 2003 June, 2015)
http://www.transtats.bts.gov/OT_Delay/ot_delaycause1.asp?display=data&pn=1
Data / Model
•
•
•
•
•
•
•
•
Total Operations: 2,278,897
On-Time Operations: 1,824,432
Proportion On-Time: 1824432/2278897 = .8006 (.80)
Will consider random samples of various sizes from
this population of operations
Y ≡ # of On-Time operations out of the sample of n
Y ~ Binomial(n , pY = 0.80)
X ≡ # of Flights sampled until the first NOT On-Time
Arrival is selected
X ~ Geometric(pX = 0.20)
Binomial Distribution – Probability Function
Binomial Probability Mass Function
n
n!
n y
n y
P Y  y | Y ~ Bin  n, p    p  y     p y 1  p  
p y 1  p 
y ! n  y  !
 y
p  y   0 y since: y  0,1,..., n 0  p  1
y  0,1,..., n 0  p  1
Binomial Expansion of  a  b  :
n
n  2 :  a  b   a 2  2ab  b 2
2
n  3 :  a  b   a 3  2a 2b  ab 2  a 2b  2ab 2  b3  a 3  3a 2b  3ab 2  b3
3
n
General n :  a  b      a n i bi
i 0  i 
n

n
n
n y
n y
p
y

p
1

p

1

p

p
 1n  1 Thus, a probability distribution










 
y 0
y 0  y 
n
n
Geometric Distribution
• Used to model the number of Bernoulli trials needed until the
first Success occurs (P(S)=p)
 First Success on Trial 1  S, y = 1  p(1)=p
 First Success on Trial 2  FS, y = 2  p(2)=(1-p)p
 First Success on Trial k  F…FS, y = k  p(k)=(1-p)k-1 p
p ( y )  (1  p ) y 1 p
y  1, 2,...



y 1
y 1
y 1
y 1
y 1
p
(
y
)

(1

p
)
p

p
(1

p
)



Setting y*  y  1 and noting that y  1, 2,...  y *  0,1,...

 p
1
  p ( y )  p  (1  p )  p 
 1

y 1
y * 0
1  (1  p)  p


y*
Binomial Distribution – Expected Value
Binomial Probability Mass Function
n
n!
n y
n y
P Y  y | Y ~ Bin  n, p    p  y     p y 1  p  
p y 1  p 
y ! n  y  !
 y
y  0,1,..., n 0  p  1
Obtaining the Mean of Y :
n
n
y 0
y 0
Y  E Y    yp  y    y
n
 Y   y
y 1
n!
n y
p y 1  p 
y ! n  y  !
n!
n y
p y 1  p 
y ! n  y  !
Summand = 0 when y  0
Pull out n, p
 n  1! p y 1 1  p n y
Now, set w  y  1  w  0,1,..., n  1 y  w  1


y

1
!
n

y
!




y 1
n 1
n 1
n  1 !

 n  1! p w 1  p  n1 w Now, set m  n  1
n  w 1
w
Y  np 
p 1  p 
 np 


w
!
n

w

1
!
w
!
n

1

w
!






w0
w0
n
 Y  np 

m
m
m!
mw
p w 1  p 
 np  1  p   p   np
w  0 w ! m  w  !
 Y  np 
Geometric Distribution – Expected Value


y 1
y 1
E Y    yp  y    y  q y 1 p 
dq y
Note: q  1  p and
 yq y 1
dq

dq y
d  y
 E Y   p 
 p q
dq y 1
y 1 dq
This interchange is justified due to nature of the convergent series.
d   y 1 
 E Y   p  q  q 
dq  y 1


q
y 1
y 1

  qz 
z 0
 E Y   p
1
1 q
since 0  q  1
 (1  q )(1)  q (1)  p  (1  q )  q  p 1
d  q 

p

 2 




2
2
dq 1  q 
(1  q )
(1  q )
p
p


Binomial Distribution – Variance and SD
Obtaining the Variance of Y : First obtain E Y Y  1  E Y 2   E Y 
n
n
y 0
y 0
E Y Y  1   y  y  1 p  y    y  y  1
n
 E Y Y  1   y  y  1
y 2
 E Y Y  1  n  n  1 p
n!
n y
p y 1  p 
y ! n  y  !
n2 !
 n  n  1 p
y  w2


 w! n  w  2 ! p 1  p 
n2 !
n2
2
 n  2  ! p w 1  p  n  2 w



w  0 w !  n  2   w  !
 E Y Y  1  n  n  1 p
w
n  w 2

w0
n2
2
n y
y 2
Now, set w  y  2 w  0,1,..., n  2
 E Y Y  1  n  n  1 p
y 2
Summand = 0 when y  0,1
Pull out n  n  1 , p 2


  y  2 ! n  y ! p 1  p 
n
2
n!
n y
p y 1  p 
y ! n  y  !
Now, set m  n  2
m
2
m
m!
mw
w
2
p
1

p

n
n

1
p
1

p

p


  
   n  n  1 p 2

w  0 w ! m  w  !
 E Y 2   E Y Y  1  E Y   n 2 p 2  np 2  np  n 2 p 2  np 1  p 
  Y2  V Y   E Y 2    E Y    n 2 p 2  np 1  p    np   np 1  p    Y  np 1  p 
2
2
Geometric Distribution – Variance and SD


2 y
d
q
E Y (Y  1)    y ( y  1)  q y 1 p   pq 

2
y 1
y 1 dq

  y 1 
q q  
 y 1

d2
 pq 2
dq
2
d
q y  pq 2

dq
y 1
d2
 pq 2
dq
 q 
d
1
2 pq
2 pq 2q
3

pq

pq

2(1

q
)
(

1)


 2


1  q 
3
2
3
dq (1  q )
p
p
1  q 


 E Y 2   E Y (Y  1)   E (Y ) 
2q 1 2(1  p)  p 2  p
 
 2
2
2
p
p
p
p
2
2 p 1 
2  p 1 1  p q
2
 V (Y )  E Y    E (Y )   2    
 2  2
2
p
p
p
p
 p
2
 
q
p2
Binomial Distribution for On-Time Flights
n  1 (Bernoulli Distribution):
1
1 y
0
1 0
p  y     0.8 y 1  0.8 
y  0,1 p  0   1 0.8   0.2   0.2
 y
E Y   1 0.8   0.8 V Y   1 0.8  0.2   0.16  Y  0.40
p 1  1 0.8   0.2 
11
1
 0.8
n2
2
2 y
p  y     0.8 y 1  0.8 
 y
p  0   1 0.8   0.2 
0
20
 0.04
y  0,1, 2
p 1  2  0.8   0.2 
1
2 1
 0.32
E Y   2  0.8   1.6 V Y   2  0.8  0.2   0.32  Y  0.566
In general, what needs to happen for p  n  1  p  n  ?
For what value of n does that occur for p  .8?
p  2   1 0.8   0.2 
2
22
 0.64
Binomial Distributions for n=1,2,3,4,10,25
• In EXCEL:
 Create a column of values 0,1,2,…,n (Say 0 is in cell
A2)
 In Cell B2, Type: =BINOM.DIST(A2,n,p,0)
 Copy and paste that cell alongside 1 (A3),…,n
 Note that the 0 at the end gives P(Y = y) = p(y)
 If you use 1 instead, you get P(Y ≤ y) = F(y)
Several Binomial Distributions with p=0.8
n
n
1
n
2
p
p
0.8
y
p(y)
y
0.2
0.8
y
0.04
0.32
0.64
p(y)
y
0.008
0.096
0.384
0.512
25
p
0.8
0
1
2
3
n
10
p
0.8
p(y)
0
1
2
n
4
p
0.8
0
1
n
3
0
1
2
3
4
p
0.8
p(y)
y
0.0016
0.0256
0.1536
0.4096
0.4096
0
1
2
3
4
5
6
7
8
9
10
0.8
p(y)
y
1.02E-07
4.1E-06
7.37E-05
0.000786
0.005505
0.026424
0.08808
0.201327
0.30199
0.268435
0.107374
1


0.8

0.4


1.6 0.565685

2.4

0.69282

3.2

0.8


8 1.264911
p(y)
3.36E-18
3.36E-16
1.61E-14
4.94E-13
1.09E-11
1.83E-10
2.43E-09
2.64E-08
2.38E-07
1.8E-06
1.15E-05
6.27E-05
0.000293
0.001171
0.004015
0.011777
0.029442
0.062349
0.110842
0.163346
0.196015
0.186681
0.135768
0.070835
0.023612
0.003778

20
2
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Probability Distribution of On-Time Flights Y ~ Bin(n=1,p=0.80)
1
0.95
0.9
0.85
0.8
0.75
0.7
0.65
0.6
0.55
0.5
p(y)
0.45
0.4
0.35
0.3
0.25
0.2
0.15
0.1
0.05
0
0
1
Probability Distribution of On-Time Flights Y ~ Bin(n=3,p=0.80)
0.7
0.65
0.6
0.55
0.5
0.45
0.4
0.35
p(y)
0.3
0.25
0.2
0.15
0.1
0.05
0
0
1
2
3
Probability Distribution of On-Time Flights Y ~ Bin(n=4,p=0.80)
0.45
0.4
0.35
0.3
0.25
p(y)
0.2
0.15
0.1
0.05
0
0
1
2
3
4
Probability Distribution of On-Time Flights Y ~ Bin(n=10,p=0.80)
0.4
0.36
0.32
0.28
0.24
0.2
p(y)
0.16
0.12
0.08
0.04
0
0
1
2
3
4
5
6
7
8
9
10
Probability Distribution of On-Time Flights Y ~ Bin(n=25,p=0.80)
0.25
0.225
0.2
0.175
0.15
0.125
p(y)
0.1
0.075
0.05
0.025
0
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Probability Distribution of On-Time Flights Y ~ Bin(n=100,p=0.80)
0.12
0.1
0.08
0.06
p(y)
0.04
0.02
0
0
3
6
9
12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60 63 66 69 72 75 78 81 84 87 90 93 96 99
Geometric Distribution Probabilities
P  X  1  p 1  p X q1X1  p X  0.20
P  X  2   p  2   p X q X21  p X q X  0.20  0.80   0.16
P  X  x   p  x   p X q Xx 1  0.20  0.80 
E X  
1
1

 5.00
p X 0.20
V X  
x 1
1  p X 1  0.20 .80


 20.00
p X2
.202
.04
 X  20  4.47
x
x
i 1
i 1
F  x   P  X  x    p  x    pX q
i 1
X
x
 pX  q
i 1
i 1
X
1  q Xx
x
 pX
 1  q Xx  1  .80 
1  qX
In general, what is the smallest x such that P  X  x   c
for fixed 0  c  1
For the Airline data, what is the smallest x such that P  X  x   0.95
Geometric Distribution
• In EXCEL:
 Create a column of values 1,2,…,Y* for some large
value of Y* (Say 1 is in cell A2)
 In Cell B2, Type: =NEGBINOM.DIST(A2-1,1,p,0)
 Copy and paste that cell alongside 1 (A3),…,Y*
 Note that the 0 at the end gives P(Y = y) = p(y)
 If you use 1 instead, you get P(Y ≤ y) = F(y)
Geometric Distribution Probabilities and CDF
Geometric (p=.20)
y
p(y)
F(y)
1
0.2
0.2
2
0.16
0.36
3
0.128
0.488
4
0.1024
0.5904
5 0.08192 0.67232
6 0.065536 0.737856
7 0.052429 0.790285
8 0.041943 0.832228
9 0.033554 0.865782
10 0.026844 0.892626
11 0.021475 0.914101
12 0.01718 0.931281
13 0.013744 0.945024
14 0.010995 0.95602
15 0.008796 0.964816
16 0.007037 0.971853
17 0.005629 0.977482
18 0.004504 0.981986
19 0.003603 0.985588
20 0.002882 0.988471
21 0.002306 0.990777
22 0.001845 0.992621
23 0.001476 0.994097
24 0.001181 0.995278
25 0.000944 0.996222
Geometric Distribution for Probability of y Trials until 1st
NON On-Time Flight
0.25
0.2
0.15
p(y)
0.1
0.05
0
1
2
3
4
5
6
7
8
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Moment-Generating Function
Define: k'  E Y k 
 ty 
ety  1  ty 
2!
2
 ty 

Assuming k'  
3!
3
 ty 

4!
4
 ...
for k  1, 2,3,....:
2
3
4


ty
ty
ty






tY
ty
m  t   E e    e p  y    1  ty 


 ...  p  y 


2!
3!
4!
y
y


t2
t3
t4
2
3
 1 p  y   t  yp  y    y p  y    y p  y    y 4 p  y   ...
2! y
3! y
4! y
y
y
t2 ' t3 ' t4 '
'
 1  t 1  2  3   4  ...
2!
3!
4!
d k m t 
k
If m  t  exists:
 m   0   k'  E Y k 
k
dt
t 0
2t ' 3t 2 ' 4t 3 '
'
Note: m '  t   0  1  2 
3 
4  ...  m '  0   1'
2!
3!
4!
6t ' 12t 2 '
'
m ''  t   0  2  3 
4  ...  m ''  0   2'
3!
4!
Moment-Generating Function – Binomial Distribution
Binomial Distribution:
n
y n
n y
n y
n y
m  t   E e    e p  y    e   p 1  p     et    p y 1  p  
y 0
y 0
y 0
 y
 y
n
n
n y
t y
t n
pe
1

p

1

p

pe









 
y 0  y 
n
tY
n
ty
ty
 m '  t   n  1  p   pet 
n 1
 pe 
t
 m ''  t   n  n  1  1  p   pet 
n2
 m '  0   n  1  p   p 
 pe 
t 2
 n  1  p   pet 
n 1
n 1
 p   np
 pe 
t
 m ''  0   n  n  1 p 2  np  n 2 p 2  np 1  p 
1'  E Y   np
2'  E Y 2   n 2 p 2  np 1  p 
Airline Values:
m  t    1  0.80   0.80et    0.20  0.80et 
n
n
   n p  np 1  p    np   np 1  p 
V Y    2'  1'
2
2
2
2
Geometric Distribution – MGF
m(t )  E  e

tY
  e
ty
q y 1 p 
y 1
p  ty y p 
pqet
t y
  e q    qe  
q y 1
q y 1
q

  qe 
t
pet
pet


1  qet 1  (1  p )et
y 1
y 1
1  (1  p)e  pe  pe  (1  p )e  pe

m 't  

1  (1  p)e 
t
t
t
t
t 2

pet
1  (1  p)et 
2
 m '  0 
p
1  (1  p) 

2
t
 p (1  p )e 2t  p (1  p )e 2t
1  (1  p)e 
t 2

p 1
  E Y 
p2 p
1  (1  p)et  pet  pet 2 1  (1  p)et   (1  p)et 
2
m ''  t  

1  (1  p)e 
pe 1  2(1  p )e  (1  p ) e   2(1  p )e  2(1  p ) e  pe 1  (1  p ) e


1  (1  p)e 
1  (1  p)e 
p 1  q  1  q 1  q  1  q 
1  q    1  
 m '' 0 


 V Y 
t 4
t
t
2
2t
t
2
2t
t
2
t 4
 
p3

t 4
2
p4
2t
p2
 
2
p2
 
 p
q
p2
Probability-Generating Functions
Define: k   E Y Y  1 ... Y  k  1
where k is a positive integer
Y is a Random Variable that takes on integer values: y  0,1, 2,...
P  t   E t

Y
   t p  y   t p  0   t p 1  t p  2   t p  3  ...
y
0
1
2
3
y 0
 1  tp 1  t 2 p  2   t 3 p  3  ...
 P '  t   0  p 1  2tp  2   3t 2 p  3  ...
 P ' 1  0  p 1  2 p  2   3 p  3  ...

 yp  y   E Y 

y 0
 P ''  t   0  0  2 1 p  2   3  2  tp  3  ...
 P '' 1  0  0  2 1 p  2   3  2  p  3  ...

 y  y  1 p  y   E Y Y  1

y 0
P
k 
d k P t 
k 

P
t  
 t  t 1  k   E Y Y  1 ... Y  k  1
k
dt
Probability-Generating Functions - Binomial
Binomial Distribution:
Note: p  n  1  p  n  2   ...  p     0
n y
n y
P  t   E t    t p  y    t   p 1  p 
y 0
y 0
 y
n
n
n
y
n y
     pt  1  p    1  p   pt 
y 0  y 

Y
n
y
y
 P '  t   n  1  p   pt 
 P ' 1  n  1  p   p 
n 1
n 1
p
p  np  E Y 
 P ''  t   n  n  1  1  p   pt 
 P '' 1  n  n  1  1  p   p 
n2
n2
p2
p 2  n  n  1  1  p   p 
For Airline Data: P  t    1  0.80   0.80t    0.20  0.80t 
n
n
n2
p 2  E Y Y  1
Geometric Distribution – PGF
P (t )  E  t

Y
  t q
y
y 1
y 1
p  y y p 
y
p   t q    tq  
q y 1
q y 1
ptq 
pt
pt
y 1

tq





q y 1
1  tq 1  (1  p )t
P 't  
1  (1  p)t  p  pt  (1  p)   p 1  (1  p)t  (1  p)t  
p
2
2
2
1  (1  p)t 
1  (1  p)t 
1  (1  p)t 
 P ' 1 
p
1  (1  p) 
2
P ''  t   2 p 1  (1  p )t 
p 1
  E Y 
p2 p

3
 (1  p)  
2 p (1  p )
1  (1  p)t 
3
2 p (1  p) 2 1  p 
 P '' 1 

 E Y Y  1 
p3
p2
2 1  p  1  1 
2  2 p  p 1 1  p
V Y  



 2
 
2
2
p
p  p
p
p
2